Skip to content

Commit

Permalink
Change SW way
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami JABER committed Jan 21, 2025
1 parent 06b36d7 commit 2489a41
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions services/webapp/src/serviceWorkerRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ function registerValidSW(swUrl: string, config?: Config) {
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
registration.update().then(() => {
registration.unregister().then(() => {
window.location.reload();
});
navigator.serviceWorker.addEventListener('controllerchange', () => {
window.location.reload(); // Reload the current page
});
registration.update();
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
Expand Down

0 comments on commit 2489a41

Please sign in to comment.