Skip to content

Commit

Permalink
feat: reset SW on local data deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Oct 28, 2024
1 parent 62f0968 commit 2c9463a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/frontend/src/features/menu/HelpMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const HelpMenu = ({ backButtonOnClick }: { backButtonOnClick: () => void
if (electric.isConnected) electric.disconnect();
localStorage.clear();
indexedDB.deleteDatabase("crvif.db");
unregisterSWs()
window.location.reload();
};
return (
Expand All @@ -23,3 +24,14 @@ export const HelpMenu = ({ backButtonOnClick }: { backButtonOnClick: () => void
</>
);
};

const unregisterSWs = async () => {
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations();

// Unregister all service workers
await Promise.all(
registrations.map(registration => registration.unregister())
);
}
};

0 comments on commit 2c9463a

Please sign in to comment.