From 1d9315d74ace26468526e5128031face050299fb Mon Sep 17 00:00:00 2001 From: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Date: Wed, 27 Mar 2019 18:27:44 +0000 Subject: [PATCH] Update sw.js --- examples/lib/sw.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/lib/sw.js b/examples/lib/sw.js index c9ccc8be..2a57f1f1 100644 --- a/examples/lib/sw.js +++ b/examples/lib/sw.js @@ -8,6 +8,22 @@ const version = (window.location.indexOf('beta') == 0) ? betaVer : ver; 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 => { console.log('Attempting to install service worker'); }); @@ -18,8 +34,7 @@ self.addEventListener('activate', function(e) { caches.keys().then(function(cacheNames) { return Promise.all( cacheNames.filter(function(cacheName){ - return cacheName.startsWith('image-sequencer-') && - cacheName != staticCacheName; + cacheName != staticCacheName; }).map(function(cacheName){ return caches.delete(cacheName); })