mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-07 04:09:17 +02:00
added version info and reload option
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { precacheAndRoute, cleanupOutdatedCaches } from 'workbox-precaching';
|
||||
import { clientsClaim } from 'workbox-core';
|
||||
import { precacheAndRoute, cleanupOutdatedCaches } from "workbox-precaching";
|
||||
import { clientsClaim } from "workbox-core";
|
||||
|
||||
self.skipWaiting();
|
||||
clientsClaim();
|
||||
@@ -10,19 +10,19 @@ cleanupOutdatedCaches();
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
// Custom precaching logic for the /api/modules endpoint
|
||||
self.addEventListener('install', (event) => {
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
caches.open('api-modules-cache').then((cache) => {
|
||||
return fetch('/api/modules')
|
||||
caches.open("api-modules-cache").then((cache) => {
|
||||
return fetch("/api/modules")
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return cache.put('/api/modules', response);
|
||||
return cache.put("/api/modules", response);
|
||||
}
|
||||
throw new Error('Failed to fetch /api/modules');
|
||||
throw new Error("Failed to fetch /api/modules");
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Precaching /api/modules failed:', error);
|
||||
console.error("Precaching /api/modules failed:", error);
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user