From 2a0b6dbfe6e6517de711cddeffecc3a767ded189 Mon Sep 17 00:00:00 2001 From: kritzl Date: Mon, 10 Jun 2024 13:55:39 +0200 Subject: [PATCH] v0.6.3: immediate update on new version (skipping 24h service worker cooldown) --- elevators.js | 1 + icons/favicon_source.svg | 5 ++++- main.js | 20 +++++++++++++++----- style.css | 2 +- style.scss | 2 +- sw.js | 21 +++++++++++++-------- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/elevators.js b/elevators.js index af261c9..4908cfb 100644 --- a/elevators.js +++ b/elevators.js @@ -232,6 +232,7 @@ async function loadOsmData() { if (!internalData.stations[stationIndex].hasOwnProperty('coordinates')) { const substitute = substituteData.filter(subs => subs.name === internalData.stations[stationIndex].name) + console.log(substitute) if (substitute.length && substitute[0].hasOwnProperty('coordinates')) { internalData.stations[stationIndex]['coordinates'] = substitute[0].coordinates; } diff --git a/icons/favicon_source.svg b/icons/favicon_source.svg index a9de5ec..028ef75 100644 --- a/icons/favicon_source.svg +++ b/icons/favicon_source.svg @@ -53,7 +53,10 @@ y="0" width="100" height="100" - id="page4" /> { - console.log('done installing sw'); - }); + navigator.serviceWorker.register("/sw.js") + .then((registration) => { + if (registration.installing) { + console.log('New Service Worker is installing...'); + } else if (registration.waiting) { + console.log('Installed new service worker. Waiting for Update (up to 24h).'); + } else if (registration.active) { + console.log('Service Worker is up to date.'); + } + }) + .catch((error) => { + // registration failed + console.error(`Registration failed with ${error}`); + }); } diff --git a/style.css b/style.css index 65f69ef..9f222c5 100644 --- a/style.css +++ b/style.css @@ -404,7 +404,7 @@ body.has-dialog { body { font-family: system-ui, ui-sans-serif, sans-serif; - font-size: 1.2rem; + font-size: 1rem; background-color: var(--bg); color: var(--text); } diff --git a/style.scss b/style.scss index 1fafb0c..a9ed6cf 100644 --- a/style.scss +++ b/style.scss @@ -171,7 +171,7 @@ body { body { font-family: system-ui, ui-sans-serif, sans-serif; - font-size: 1.2rem; + font-size: 1rem; // colors background-color: var(--bg); diff --git a/sw.js b/sw.js index 5053d14..fbfa986 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const version = '0.6.2' +const version = '0.6.3' const consolePrefix = `[SW v${version}] ` const cacheName = `hvvstuhl-${version}`; @@ -36,13 +36,16 @@ const contentToCache = [ // Service worker Install: Cache all files self.addEventListener("install", (e) => { - console.log("[Service Worker] Wird installiert...."); + console.log(`${consolePrefix}Wird installiert....`); e.waitUntil( (async () => { const cache = await caches.open(cacheName); - console.log("[Service Worker] Cache wird aufgebaut..."); + console.log(`${consolePrefix} Cache wird aufgebaut...`); await cache.addAll(contentToCache); - console.log("[Service Worker] FERTIG"); + console.log(`${consolePrefix} > FERTIG`); + console.log(`${consolePrefix} Versuche Wartezeit zu überspringen...`); + await self.skipWaiting(); + console.log(`${consolePrefix} > Erfolgreich`); })(), ); }); @@ -60,8 +63,10 @@ const deleteOldCaches = async () => { self.addEventListener("activate", (event) => { event.waitUntil( (async () => { - await deleteOldCaches() - await clients.claim(); + await deleteOldCaches(); + console.log(`${consolePrefix}Versuche Clients zu beanspruchen...`); + await self.clients.claim(); + console.log(`${consolePrefix} > Erfolgreich`); })(), ); }); @@ -79,12 +84,12 @@ self.addEventListener("fetch", (e) => { const r = await caches.match(e.request); if (r) { - console.log(`${consolePrefix} Im Cache gefunden.`); + console.log(`${consolePrefix} > Im Cache gefunden.`); return r; } const response = await fetch(e.request); const cache = await caches.open(cacheName); - console.log(`${consolePrefix} Nicht gefunden. Aktualisiere Cache: ${path}`); + console.log(`${consolePrefix} > Nicht gefunden. Aktualisiere Cache: ${path}`); await cache.put(e.request, response.clone()); return response; }else{