mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-29 21:01:27 +00:00
fix: use .get() for Map lookup. fix: correctly set url and url_paths. fix: null check to throw error.
This commit is contained in:
@@ -93,25 +93,24 @@ class FeatureFlagService extends BaseService {
|
||||
}
|
||||
return { options, value };
|
||||
})();
|
||||
|
||||
|
||||
if ( ! this.known_flags.has(permission) ) {
|
||||
this.known_flags.set(permission, true);
|
||||
}
|
||||
|
||||
if ( this.known_flags[permission].$ === 'config-flag' ) {
|
||||
return this.known_flags[permission].value;
|
||||
if(this.known_flags.get(permission)?.$ === "config-flag") {
|
||||
return this.known_flags.get(permission)?.value;
|
||||
}
|
||||
|
||||
const actor = options.actor ?? Context.get('actor');
|
||||
|
||||
if ( this.known_flags[permission].$ === 'function-flag' ) {
|
||||
return await this.known_flags[permission].fn({
|
||||
if ( this.known_flags.get(permission)?.$ === 'function-flag' ) {
|
||||
return await this.known_flags.get(permission)?.fn({
|
||||
...options,
|
||||
actor
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const svc_permission = this.services.get('permission');
|
||||
const reading = await svc_permission.scan(actor, `feature:${permission}`);
|
||||
const l = PermissionUtil.reading_to_options(reading);
|
||||
|
||||
@@ -45,7 +45,7 @@ class ShareService extends BaseService {
|
||||
svc_featureFlag.register('share', {
|
||||
$: 'function-flag',
|
||||
fn: async ({ actor }) => {
|
||||
const user = actor.type.user;
|
||||
const user = actor.type.user ?? null;
|
||||
if ( ! user ) {
|
||||
throw new Error('expected user');
|
||||
}
|
||||
|
||||
@@ -153,8 +153,10 @@ if(jQuery){
|
||||
}
|
||||
|
||||
window.initgui = async function(options){
|
||||
let url = new URL(window.location);
|
||||
url = url.href;
|
||||
const url = new URL(window.location).href;
|
||||
window.url = url;
|
||||
const url_paths = window.location.pathname.split('/').filter(element => element);
|
||||
window.url_paths = url_paths
|
||||
|
||||
let picked_a_user_for_sdk_login = false;
|
||||
|
||||
@@ -199,16 +201,14 @@ window.initgui = async function(options){
|
||||
// will hold the result of the whoami API call
|
||||
let whoami;
|
||||
|
||||
window.url_paths = window.location.pathname.split('/').filter(element => element);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Extract 'action' from URL
|
||||
//--------------------------------------------------------------------------------------
|
||||
let action;
|
||||
if(url_paths[0]?.toLocaleLowerCase() === 'action' && url_paths[1]){
|
||||
action = url_paths[1].toLowerCase();
|
||||
if (window.url_paths[0]?.toLocaleLowerCase() === 'action' && window.url_paths[1]) {
|
||||
action = window.url_paths[1].toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Determine if we are in full-page mode
|
||||
// i.e. https://puter.com/app/<app_name>/?puter.fullpage=true
|
||||
@@ -789,6 +789,7 @@ window.initgui = async function(options){
|
||||
console.error('Error:', error);
|
||||
})
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Desktop Background
|
||||
// If we're in fullpage/emebedded/Auth Popup mode, we don't want to load the custom background
|
||||
|
||||
Reference in New Issue
Block a user