This commit is contained in:
tamaina 2021-02-13 15:04:46 +09:00
parent 66417c8753
commit 61a19a598b
2 changed files with 13 additions and 10 deletions

View File

@ -31,7 +31,8 @@ class SwLang {
const localeUrl = `/assets/locales/${await this.lang}.${_VERSION_}.json`; const localeUrl = `/assets/locales/${await this.lang}.${_VERSION_}.json`;
let localeRes = await caches.match(localeUrl); let localeRes = await caches.match(localeUrl);
if (!localeRes) { // _DEV_がtrueの場合は常に最新化
if (!localeRes || _DEV_) {
localeRes = await fetch(localeUrl); localeRes = await fetch(localeUrl);
const clone = localeRes?.clone(); const clone = localeRes?.clone();
if (!clone?.clone().ok) Error('locale fetching error'); if (!clone?.clone().ok) Error('locale fetching error');

View File

@ -33,10 +33,10 @@ self.addEventListener('activate', ev => {
}); });
//#endregion //#endregion
// TODO: 消せるかも ref. https://github.com/syuilo/misskey/pull/7108#issuecomment-774573666
//#region When: Fetching //#region When: Fetching
self.addEventListener('fetch', ev => { self.addEventListener('fetch', ev => {
if (ev.request.method !== 'GET' || ev.request.url.startsWith(apiUrl)) return; /*
if (ev.request.url.startsWith(`${location.origin}/assets/locales/`)) {
ev.respondWith( ev.respondWith(
caches.match(ev.request) caches.match(ev.request)
.then(response => { .then(response => {
@ -44,6 +44,8 @@ self.addEventListener('fetch', ev => {
}) })
.catch(() => new Response('SW cathces error while fetching. You may not be connected to the Internet, or the server may be down.', { status: 200, statusText: 'OK SW' })) .catch(() => new Response('SW cathces error while fetching. You may not be connected to the Internet, or the server may be down.', { status: 200, statusText: 'OK SW' }))
); );
}
*/
}); });
//#endregion //#endregion