diff options
author | rstular <rok@stular.eu> | 2020-01-29 17:54:19 +0100 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-01-29 17:54:19 +0100 |
commit | ad02878561178429e4b8fcbd4594d9ce78f4c407 (patch) | |
tree | 075afb9e8bdc32925743a076f4bf1e2af1d7743c /sw.js | |
parent | TOS & PP changes (diff) | |
download | beziapp-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.js | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -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 +}); |