|
|
@ -60,24 +60,15 @@ registerRoute(
|
|
|
|
self.addEventListener('install', function(event) {
|
|
|
|
self.addEventListener('install', function(event) {
|
|
|
|
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root)));
|
|
|
|
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root)));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
self.addEventListener('activate', function(event) {
|
|
|
|
self.addEventListener('activate', function(event) {
|
|
|
|
event.waitUntil(self.clients.claim());
|
|
|
|
event.waitUntil(self.clients.claim());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
self.addEventListener('fetch', function(event) {
|
|
|
|
self.addEventListener('fetch', function(event) {
|
|
|
|
const url = new URL(event.request.url);
|
|
|
|
const url = new URL(event.request.url);
|
|
|
|
|
|
|
|
|
|
|
|
if (url.pathname.startsWith('/web/')) {
|
|
|
|
if (url.pathname === '/auth/sign_out') {
|
|
|
|
const asyncResponse = fetchRoot();
|
|
|
|
|
|
|
|
const asyncCache = openWebCache();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event.respondWith(asyncResponse.then(
|
|
|
|
|
|
|
|
response => {
|
|
|
|
|
|
|
|
const clonedResponse = response.clone();
|
|
|
|
|
|
|
|
asyncCache.then(cache => cache.put('/', clonedResponse)).catch();
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
() => asyncCache.then(cache => cache.match('/'))));
|
|
|
|
|
|
|
|
} else if (url.pathname === '/auth/sign_out') {
|
|
|
|
|
|
|
|
const asyncResponse = fetch(event.request);
|
|
|
|
const asyncResponse = fetch(event.request);
|
|
|
|
const asyncCache = openWebCache();
|
|
|
|
const asyncCache = openWebCache();
|
|
|
|
|
|
|
|
|
|
|
|