|
|
@ -1,9 +1,9 @@
|
|
|
|
import { freeStorage, storageFreeable } from '../storage/modifier';
|
|
|
|
// import { freeStorage, storageFreeable } from '../storage/modifier';
|
|
|
|
import './web_push_notifications';
|
|
|
|
import './web_push_notifications';
|
|
|
|
|
|
|
|
|
|
|
|
function openSystemCache() {
|
|
|
|
// function openSystemCache() {
|
|
|
|
return caches.open('mastodon-system');
|
|
|
|
// return caches.open('mastodon-system');
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
function openWebCache() {
|
|
|
|
function openWebCache() {
|
|
|
|
return caches.open('mastodon-web');
|
|
|
|
return caches.open('mastodon-web');
|
|
|
@ -13,8 +13,8 @@ function fetchRoot() {
|
|
|
|
return fetch('/', { credentials: 'include', redirect: 'manual' });
|
|
|
|
return fetch('/', { credentials: 'include', redirect: 'manual' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const firefox = navigator.userAgent.match(/Firefox\/(\d+)/);
|
|
|
|
// const firefox = navigator.userAgent.match(/Firefox\/(\d+)/);
|
|
|
|
const invalidOnlyIfCached = firefox && firefox[1] < 60;
|
|
|
|
// const invalidOnlyIfCached = firefox && firefox[1] < 60;
|
|
|
|
|
|
|
|
|
|
|
|
// Cause a new version of a registered Service Worker to replace an existing one
|
|
|
|
// Cause a new version of a registered Service Worker to replace an existing one
|
|
|
|
// that is already installed, and replace the currently active worker on open pages.
|
|
|
|
// that is already installed, and replace the currently active worker on open pages.
|
|
|
@ -52,7 +52,7 @@ self.addEventListener('fetch', function(event) {
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
return response;
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
} else if (storageFreeable && (ATTACHMENT_HOST ? url.host === ATTACHMENT_HOST : url.pathname.startsWith('/system/'))) {
|
|
|
|
} /* else if (storageFreeable && (ATTACHMENT_HOST ? url.host === ATTACHMENT_HOST : url.pathname.startsWith('/system/'))) {
|
|
|
|
event.respondWith(openSystemCache().then(cache => {
|
|
|
|
event.respondWith(openSystemCache().then(cache => {
|
|
|
|
return cache.match(event.request.url).then(cached => {
|
|
|
|
return cache.match(event.request.url).then(cached => {
|
|
|
|
if (cached === undefined) {
|
|
|
|
if (cached === undefined) {
|
|
|
@ -73,5 +73,5 @@ self.addEventListener('fetch', function(event) {
|
|
|
|
return cached;
|
|
|
|
return cached;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
});
|
|
|
|
});
|
|
|
|