Skip to content

Commit

Permalink
fix: use await for extension storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Dec 20, 2024
1 parent 08b3bee commit b8d3db4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/applications/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,20 @@ let isResetInProgress = false;
* Reset all permissions for all apps
*/
export const resetAllPermissions = async (): Promise<void> => {
// Check both storage and memory flags
if (ExtensionStorage.get(IS_PERMISSIONS_RESET) || isResetInProgress) {
return;
}

try {
const isPermissionsReset = await ExtensionStorage.get(IS_PERMISSIONS_RESET);
// Check both storage and memory flags
if (isPermissionsReset || isResetInProgress) {
return;
}

// Set the in-progress flag
isResetInProgress = true;

// Get and validate connected apps
const connectedApps = (await ExtensionStorage.get("apps")) || [];
if (!Array.isArray(connectedApps) || connectedApps.length === 0) {
ExtensionStorage.set(IS_PERMISSIONS_RESET, true);
await ExtensionStorage.set(IS_PERMISSIONS_RESET, true);
return;
}

Expand Down Expand Up @@ -109,7 +110,7 @@ export const resetAllPermissions = async (): Promise<void> => {
}

// Mark as complete
ExtensionStorage.set(IS_PERMISSIONS_RESET, true);
await ExtensionStorage.set(IS_PERMISSIONS_RESET, true);
} catch (error) {
console.error("Error in resetAllPermissions:", error);
} finally {
Expand Down

0 comments on commit b8d3db4

Please sign in to comment.