Skip to content

Commit

Permalink
✨ [PWA] Update the public service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Jul 22, 2024
1 parent 7459c3e commit bea860c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions public/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
// Reference:
// https://vite-pwa-org.netlify.app/guide/unregister-service-worker.html#unregister-service-worker
// To be placed in: public/sw.js

/*
self.addEventListener('install', (e) => {
// The old `dulmage.me` site used a file called `service-worker.js`,
// where as our new setup uses a `sw.js` file. Therefor, we can
// replace that old file with this code, which specifically uninstalls
// the previous registration (of the same name).

self.addEventListener('install', (_event) => {
self.skipWaiting();
});

self.addEventListener('activate', (e) => {
self.addEventListener('activate', (_event) => {
self.registration
.unregister()
.then(() => self.clients.matchAll())
.then((clients) => {
clients.forEach((client) => {
if (client instanceof WindowClient) client.navigate(client.url);
if (client instanceof WindowClient) {
client.navigate(client.url);
}
});

return Promise.resolve();
})
.then(() => {
Expand All @@ -27,4 +33,3 @@ self.addEventListener('activate', (e) => {
});
});
});
*/

0 comments on commit bea860c

Please sign in to comment.