crabfit/frontend/public/sw.js
2023-06-09 03:29:42 +10:00

20 lines
492 B
JavaScript

// TODO: This is temporary, as I've made the decision to move away
// from a PWA, so must remove all existing service workers
self.addEventListener("install", () => {
self.skipWaiting()
})
self.addEventListener("activate", () => {
self.registration
.unregister()
.then(() => self.clients.matchAll())
.then((clients) => {
clients.forEach((client) => {
if (client.url && "navigate" in client) {
client.navigate(client.url)
}
})
})
})