Skip to content

Commit

Permalink
fix: use .get() for Map lookup. fix: correctly set url and url_paths.…
Browse files Browse the repository at this point in the history
… fix: null check to throw error.
  • Loading branch information
Raiu authored and KernelDeimos committed Jan 14, 2025
1 parent 7fa0822 commit 78ac033
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
11 changes: 5 additions & 6 deletions src/backend/src/services/FeatureFlagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/backend/src/services/ShareService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
15 changes: 8 additions & 7 deletions src/gui/src/initgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 78ac033

Please sign in to comment.