diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-06-08 23:04:24 +0200 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-06-08 23:04:24 +0200 |
commit | 0d4d63927cb2b608c65641859bfe43ba6b17b204 (patch) | |
tree | fa69159702a706907357893e20ce46f0c71de7a6 /assets | |
parent | DNM+in case you haven't read the prev. commit (diff) | |
download | beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar.gz beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar.bz2 beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar.lz beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar.xz beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.tar.zst beziapp-0d4d63927cb2b608c65641859bfe43ba6b17b204.zip |
Diffstat (limited to 'assets')
-rw-r--r-- | assets/root/sw.js.bvr | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/assets/root/sw.js.bvr b/assets/root/sw.js.bvr index 1a823d4..45ac9dd 100644 --- a/assets/root/sw.js.bvr +++ b/assets/root/sw.js.bvr @@ -118,6 +118,30 @@ self.addEventListener("activate", evt => { ); }); +async function sw_asynclycheckversion (data) { + try { + var names = await caches.keys(); + console.log("[sw.js] checkversion: ***** checkversion v0 for BežiApp ***** hello, world!"); + if(!(data.valid_cache_name == undefined || data.valid_cache_name == null || data.valid_cache_name == "")) { + var valid_cache_name = data.valid_cache_name; + console.log("[sw.js] checkversion: requested version (cachename) " + valid_cache_name); + } else { + var valid_cache_name = static_cache_name; + console.log("[sw.js] checkversion: no version to keep specified, using current "+valid_cache_name+", but that makes no sense to me."); + } + console.log("[sw.js] checkversion: deleting caches that don't match that cache name ..."); + for (let name of names) { + if(valid_cache_name != name) { + caches.delete(name); + console.log("[sw.js] checkversion: done requesting delete of cache " + name); + } + } + console.log("[sw.js] checkversion: done, exiting!"); + } catch (e) { + console.log("[sw.js] checkversion: !!! ERRORS! (caught)"); + } +} + self.addEventListener("message", event => { if (event.data) { @@ -141,27 +165,7 @@ self.addEventListener("message", event => { } }); } else if (data.action.startsWith("checkversion")) { - try { - var names = await caches.keys(); - console.log("[sw.js] checkversion: ***** checkversion v0 for BežiApp ***** hello, world!"); - if(!(data.valid_cache_name == undefined || data.valid_cache_name == null || data.valid_cache_name == "")) { - var valid_cache_name = data.valid_cache_name; - console.log("[sw.js] checkversion: requested version (cachename) " + valid_cache_name); - } else { - var valid_cache_name = static_cache_name; - console.log("[sw.js] checkversion: no version to keep specified, using current "+valid_cache_name+", but that makes no sense to me."); - } - console.log("[sw.js] checkversion: deleting caches that don't match that cache name ..."); - for (let name of names) { - if(valid_cache_name != name) { - caches.delete(name); - console.log("[sw.js] checkversion: done requesting delete of cache " + name); - } - } - console.log("[sw.js] checkversion: done, exiting!"); - } catch (e) { - console.log("[sw.js] checkversion: !!! ERRORS! (caught)"); - } + sw_asynclycheckversion(data); } } }); |