v0.6.3: immediate update on new version (skipping 24h service worker cooldown)
This commit is contained in:
parent
12048f3a49
commit
2a0b6dbfe6
6 changed files with 35 additions and 16 deletions
|
@ -232,6 +232,7 @@ async function loadOsmData() {
|
||||||
|
|
||||||
if (!internalData.stations[stationIndex].hasOwnProperty('coordinates')) {
|
if (!internalData.stations[stationIndex].hasOwnProperty('coordinates')) {
|
||||||
const substitute = substituteData.filter(subs => subs.name === internalData.stations[stationIndex].name)
|
const substitute = substituteData.filter(subs => subs.name === internalData.stations[stationIndex].name)
|
||||||
|
console.log(substitute)
|
||||||
if (substitute.length && substitute[0].hasOwnProperty('coordinates')) {
|
if (substitute.length && substitute[0].hasOwnProperty('coordinates')) {
|
||||||
internalData.stations[stationIndex]['coordinates'] = substitute[0].coordinates;
|
internalData.stations[stationIndex]['coordinates'] = substitute[0].coordinates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,10 @@
|
||||||
y="0"
|
y="0"
|
||||||
width="100"
|
width="100"
|
||||||
height="100"
|
height="100"
|
||||||
id="page4" /></sodipodi:namedview><defs
|
id="page4"
|
||||||
|
inkscape:export-filename="favicon-transparent.svg"
|
||||||
|
inkscape:export-xdpi="130.048"
|
||||||
|
inkscape:export-ydpi="130.048" /></sodipodi:namedview><defs
|
||||||
id="defs1" /><g
|
id="defs1" /><g
|
||||||
inkscape:label="Layer 1"
|
inkscape:label="Layer 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
|
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.5 KiB |
20
main.js
20
main.js
|
@ -1,4 +1,4 @@
|
||||||
const version = '0.6.2'
|
const version = '0.6.3'
|
||||||
const minorVersion = version.split('.').splice(0, 2).join('.');
|
const minorVersion = version.split('.').splice(0, 2).join('.');
|
||||||
const numberFormat = new Intl.NumberFormat('de-DE', {
|
const numberFormat = new Intl.NumberFormat('de-DE', {
|
||||||
maximumFractionDigits: 1
|
maximumFractionDigits: 1
|
||||||
|
@ -34,8 +34,18 @@ function closeDialog(selector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
console.log('installing sw');
|
navigator.serviceWorker.register("/sw.js")
|
||||||
navigator.serviceWorker.register("/sw.js").then((registration) => {
|
.then((registration) => {
|
||||||
console.log('done installing sw');
|
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}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,7 +404,7 @@ body.has-dialog {
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: system-ui, ui-sans-serif, sans-serif;
|
font-family: system-ui, ui-sans-serif, sans-serif;
|
||||||
font-size: 1.2rem;
|
font-size: 1rem;
|
||||||
background-color: var(--bg);
|
background-color: var(--bg);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ body {
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: system-ui, ui-sans-serif, sans-serif;
|
font-family: system-ui, ui-sans-serif, sans-serif;
|
||||||
font-size: 1.2rem;
|
font-size: 1rem;
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
background-color: var(--bg);
|
background-color: var(--bg);
|
||||||
|
|
21
sw.js
21
sw.js
|
@ -1,4 +1,4 @@
|
||||||
const version = '0.6.2'
|
const version = '0.6.3'
|
||||||
const consolePrefix = `[SW v${version}] `
|
const consolePrefix = `[SW v${version}] `
|
||||||
|
|
||||||
const cacheName = `hvvstuhl-${version}`;
|
const cacheName = `hvvstuhl-${version}`;
|
||||||
|
@ -36,13 +36,16 @@ const contentToCache = [
|
||||||
|
|
||||||
// Service worker Install: Cache all files
|
// Service worker Install: Cache all files
|
||||||
self.addEventListener("install", (e) => {
|
self.addEventListener("install", (e) => {
|
||||||
console.log("[Service Worker] Wird installiert....");
|
console.log(`${consolePrefix}Wird installiert....`);
|
||||||
e.waitUntil(
|
e.waitUntil(
|
||||||
(async () => {
|
(async () => {
|
||||||
const cache = await caches.open(cacheName);
|
const cache = await caches.open(cacheName);
|
||||||
console.log("[Service Worker] Cache wird aufgebaut...");
|
console.log(`${consolePrefix} Cache wird aufgebaut...`);
|
||||||
await cache.addAll(contentToCache);
|
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) => {
|
self.addEventListener("activate", (event) => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
(async () => {
|
(async () => {
|
||||||
await deleteOldCaches()
|
await deleteOldCaches();
|
||||||
await clients.claim();
|
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);
|
const r = await caches.match(e.request);
|
||||||
if (r) {
|
if (r) {
|
||||||
console.log(`${consolePrefix} Im Cache gefunden.`);
|
console.log(`${consolePrefix} > Im Cache gefunden.`);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
const response = await fetch(e.request);
|
const response = await fetch(e.request);
|
||||||
const cache = await caches.open(cacheName);
|
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());
|
await cache.put(e.request, response.clone());
|
||||||
return response;
|
return response;
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue