Skip to content

Commit

Permalink
fix Welcome.js: readd allPolicies variable and add delete allPolicies…
Browse files Browse the repository at this point in the history
… logic
  • Loading branch information
tienifr committed Jan 27, 2023
1 parent 8c041bf commit 408f972
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/libs/actions/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ Onyx.connect({
},
});

const allPolicies = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,
callback: (val, key) => {
if (!val || !key) {
if (!key) {
return;
}

if (val === null || val === undefined) {
delete allPolicies[key];
return;
}

Policy.allPolicies[key] = {...Policy.allPolicies[key], ...val};
allPolicies[key] = {...allPolicies[key], ...val};
},
});

Expand Down Expand Up @@ -119,7 +125,7 @@ function show({routes, showCreateMenu}) {

// If user is not already an admin of a free policy and we are not navigating them to their workspace or creating a new workspace via workspace/new then
// we will show the create menu.
if (!Policy.isAdminOfFreePolicy(Policy.allPolicies) && !isDisplayingWorkspaceRoute) {
if (!Policy.isAdminOfFreePolicy(allPolicies) && !isDisplayingWorkspaceRoute) {
showCreateMenu();
}
});
Expand Down

0 comments on commit 408f972

Please sign in to comment.