2019-11-21 00:47:31 +01:00
|
|
|
const CACHE_NAME = "fwdekker-%%VERSION_NUMBER%%";
|
|
|
|
const CACHE_FILES = [
|
2020-04-12 12:02:58 +02:00
|
|
|
"bundle.js",
|
2021-04-24 22:29:23 +02:00
|
|
|
"favicon.ico",
|
2019-11-21 00:47:31 +01:00
|
|
|
"favicon.png",
|
2021-04-24 22:29:23 +02:00
|
|
|
"favicon.svg",
|
2021-03-25 21:18:37 +01:00
|
|
|
"icon_128x128.png",
|
|
|
|
"icon_144x144.png",
|
|
|
|
"icon_152x152.png",
|
|
|
|
"icon_192x192.png",
|
|
|
|
"icon_512x512.png",
|
2021-04-24 22:29:23 +02:00
|
|
|
"icon_ios.png",
|
|
|
|
"index.html",
|
|
|
|
"main.css",
|
|
|
|
"manifest.json",
|
|
|
|
"plain.js",
|
2019-11-21 00:47:31 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
self.addEventListener("install", event =>
|
|
|
|
event.waitUntil(
|
|
|
|
caches.open(CACHE_NAME)
|
|
|
|
.then(cache => cache.addAll(CACHE_FILES))
|
|
|
|
.then(self.skipWaiting())
|
2020-04-12 12:02:58 +02:00
|
|
|
.catch(error => console.error(error))
|
2019-11-21 00:47:31 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
self.addEventListener("activate", event =>
|
|
|
|
event.waitUntil(
|
|
|
|
caches.keys()
|
2020-04-12 12:02:58 +02:00
|
|
|
.then(cacheNames => cacheNames.filter(it => ![CACHE_NAME].includes(it)))
|
2019-11-21 00:47:31 +01:00
|
|
|
.then(cachesToDelete => Promise.all(cachesToDelete.map(it => caches.delete(it))))
|
|
|
|
.then(() => self.clients.claim())
|
2020-04-12 12:02:58 +02:00
|
|
|
.catch(error => console.error(error))
|
2019-11-21 00:47:31 +01:00
|
|
|
)
|
|
|
|
);
|