Files
mischlabs/sw.js
Kroonk 4bb07122ac
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 11s
fix: avoid invalid Nextcloud browser login flow
2026-05-21 22:48:02 +02:00

59 lines
1.4 KiB
JavaScript

const CACHE_NAME = 'mischlabs-pwa-v11';
const APP_SHELL = [
'/',
'/index.html',
'/offline.html',
'/style.css?v=27',
'/app.js?v=29',
'/services.json?v=1',
'/manifest.webmanifest?v=3',
'/icons/icon-192.png',
'/icons/icon-512.png',
'/icons/apple-touch-icon-v2.png'
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => cache.addAll(APP_SHELL))
);
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) => (
Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key)))
))
);
self.clients.claim();
});
self.addEventListener('fetch', (event) => {
const request = event.request;
if (request.method !== 'GET') {
return;
}
if (request.mode === 'navigate') {
event.respondWith(
fetch(request).catch(() => caches.match('/offline.html'))
);
return;
}
event.respondWith(
caches.match(request).then((cached) => (
cached || fetch(request).then((response) => {
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
}
const responseToCache = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, responseToCache));
return response;
})
))
);
});