Commit 1608ea13 authored by Julien Enselme's avatar Julien Enselme

Fix response in offline mode

With the previous implementation, we could go into the block that handles offline
when we were not offline because of how the changing worked. This resulted in some
pages being completely inaccessible and the display of the browser's error page on
others.
parent 42ae7afd
......@@ -55,16 +55,16 @@ self.addEventListener('fetch', (event) => {
.catch(err => {
console.warn('[SW] Network request failed, app is probably offline', err);
return caches.open(staticCacheName)
})
.then(cache => {
// If the request expects an HTML response, we display the offline page.
if (event.request.headers.get('accept').includes('text/html')) {
return cache.match('/offline/');
}
.then((cache) => {
// If the request expects an HTML response, we display the offline page.
if (event.request.headers.get('accept').includes('text/html')) {
return cache.match('/offline/');
}
return Promise.reject()
})
.catch(err => console.warn('[SW] failed to get response from network and cache.', err));
return Promise.reject();
})
.catch(err => console.warn('[SW] failed to get response from network and cache.', err));
});
}),
);
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment