summaryrefslogtreecommitdiffstats
path: root/sw.js
diff options
context:
space:
mode:
authorrstular <rok@stular.eu>2020-01-29 17:54:19 +0100
committerrstular <rok@stular.eu>2020-01-29 17:54:19 +0100
commitad02878561178429e4b8fcbd4594d9ce78f4c407 (patch)
tree075afb9e8bdc32925743a076f4bf1e2af1d7743c /sw.js
parentTOS & PP changes (diff)
downloadbeziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar.gz
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar.bz2
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar.lz
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar.xz
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.tar.zst
beziapp-ad02878561178429e4b8fcbd4594d9ce78f4c407.zip
Diffstat (limited to '')
-rw-r--r--sw.js27
1 files changed, 17 insertions, 10 deletions
diff --git a/sw.js b/sw.js
index f733ff6..3e38576 100644
--- a/sw.js
+++ b/sw.js
@@ -1,5 +1,5 @@
// Change version to cause cache refresh
-const static_cache_name = "site-static-v1.0.1";
+const static_cache_name = "site-static-v1.0.2";
// Got them with du -a and minor cleaning up
const assets = [
"/img/avatars/asijanec.png",
@@ -72,22 +72,29 @@ const assets = [
"/",
"/index.html",
"/login.html",
- "/logout.js"
+ "/logout.html"
];
importScripts("/js/lib/localforage.min.js");
self.addEventListener("install", (evt) => {
// Add localforage.clear() if storage purge is required
- evt.waitUntil(
- localforage.clear()
- );
-
- evt.waitUntil(
+ evt.waitUntil(async function () {
+ localforage.clear();
caches.open(static_cache_name).then((cache) => {
cache.addAll(assets);
- })
- );
+ });
+
+ if (!evt.clientId) return;
+ const client = await clients.get(event.clientId);
+
+ if (!client) return;
+
+ client.postMessage({
+ msg: "install"
+ });
+
+ });
});
// Delete old caches
@@ -106,4 +113,4 @@ self.addEventListener("fetch", (evt) => {
evt.respondWith(caches.match(evt.request).then((cache_res) => {
return cache_res || fetch(evt.request);
}))
-}); \ No newline at end of file
+});