diff --git a/sw.js b/sw.js index 7f1aeed..52b91d0 100644 --- a/sw.js +++ b/sw.js @@ -1,5 +1,5 @@ -const CACHE = 'ns-v22'; -const PRECACHE = ['/', 'index.html', 'styles.css', 'app.js', 'sw.js', 'manifest.json', 'icon.svg']; +const CACHE = 'ns-v23'; +const PRECACHE = ['/', 'index.html', 'styles.css', 'app.js', 'manifest.json', 'icon.svg']; const SKIP_URLS = ['/rest/stream', '/rest/download', '/config.js']; self.addEventListener('install', e => { @@ -9,11 +9,12 @@ self.addEventListener('install', e => { self.addEventListener('activate', e => { e.waitUntil( - caches.keys().then(keys => - Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k))) - ) + caches.keys() + .then(keys => Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))) + .then(() => self.clients.claim()) + .then(() => self.clients.matchAll({type: 'window', includeUncontrolled: true})) + .then(clients => clients.forEach(c => c.navigate(c.url))) ); - self.clients.claim(); }); self.addEventListener('fetch', e => {