mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-16 13:20:01 +01:00
Update sw.js
This commit is contained in:
committed by
GitHub
parent
508d1d8f71
commit
1d9315d74a
@@ -8,6 +8,22 @@ const version = (window.location.indexOf('beta') == 0) ? betaVer : ver;
|
|||||||
|
|
||||||
const staticCacheName = `image-sequencer-static-v${version}`;
|
const staticCacheName = `image-sequencer-static-v${version}`;
|
||||||
|
|
||||||
|
const isVersionNewer = (version, old) => {
|
||||||
|
version = version.split('.');
|
||||||
|
var major = version[0],
|
||||||
|
minor = version[1],
|
||||||
|
patch = version[2];
|
||||||
|
old = old.split('.');
|
||||||
|
var oldMajor = old[0],
|
||||||
|
oldMinor = old[1],
|
||||||
|
oldPatch = old[2];
|
||||||
|
|
||||||
|
if (major > oldMajor) return true
|
||||||
|
else if (minor > oldMinor) return true
|
||||||
|
else if (patch > oldPatch) return true
|
||||||
|
else return false
|
||||||
|
}
|
||||||
|
|
||||||
self.addEventListener('install', event => {
|
self.addEventListener('install', event => {
|
||||||
console.log('Attempting to install service worker');
|
console.log('Attempting to install service worker');
|
||||||
});
|
});
|
||||||
@@ -18,7 +34,6 @@ self.addEventListener('activate', function(e) {
|
|||||||
caches.keys().then(function(cacheNames) {
|
caches.keys().then(function(cacheNames) {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
cacheNames.filter(function(cacheName){
|
cacheNames.filter(function(cacheName){
|
||||||
return cacheName.startsWith('image-sequencer-') &&
|
|
||||||
cacheName != staticCacheName;
|
cacheName != staticCacheName;
|
||||||
}).map(function(cacheName){
|
}).map(function(cacheName){
|
||||||
return caches.delete(cacheName);
|
return caches.delete(cacheName);
|
||||||
|
|||||||
Reference in New Issue
Block a user