mirror of
https://github.com/paricafe/misskey.git
synced 2025-03-25 09:09:26 -05:00
fix sw cache
This commit is contained in:
parent
a06eeb24f5
commit
0863a6d393
1 changed files with 10 additions and 2 deletions
|
@ -13,12 +13,20 @@ import { swLang } from '@/scripts/lang.js';
|
|||
import * as swos from '@/scripts/operations.js';
|
||||
|
||||
const STATIC_CACHE_NAME = `misskey-static-${_VERSION_}`;
|
||||
const PATHS_TO_CACHE = ['/assets/','/emoji/','/twemoji/','/fluent-emoji/','/vite/'];
|
||||
const PATHS_TO_CACHE = ['/assets/', '/emoji/', '/twemoji/', '/fluent-emoji/', '/vite/'];
|
||||
|
||||
async function cacheWithFallback(cache, paths) {
|
||||
for (const path of paths) {
|
||||
try {
|
||||
await cache.add(new Request(path, { credentials: 'same-origin' }));
|
||||
} catch (error) {}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.addEventListener('install', (ev) => {
|
||||
ev.waitUntil((async () => {
|
||||
const cache = await caches.open(STATIC_CACHE_NAME);
|
||||
await cache.addAll(PATHS_TO_CACHE);
|
||||
await cacheWithFallback(cache, PATHS_TO_CACHE);
|
||||
await globalThis.skipWaiting();
|
||||
})());
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue