Fix: Update-Check vergleicht Server-Version mit lokaler — lädt Seite neu wenn Update gefunden, SW by-v561
This commit is contained in:
parent
7cf60a848f
commit
c657ac6ab8
3 changed files with 18 additions and 5 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '537'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '538'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
const APP_VERSION = '1.1.3'; // ← semantische Version, wird bei make release gesetzt
|
const APP_VERSION = '1.1.3'; // ← semantische Version, wird bei make release gesetzt
|
||||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -604,14 +604,27 @@ window.Page_settings = (() => {
|
||||||
}
|
}
|
||||||
if (btn) btn.textContent = 'Prüfe…';
|
if (btn) btn.textContent = 'Prüfe…';
|
||||||
try {
|
try {
|
||||||
|
// Aktuelle Version vom Server holen (no-cache)
|
||||||
|
const serverResp = await fetch('/js/app.js', { cache: 'no-store' });
|
||||||
|
const serverText = await serverResp.text();
|
||||||
|
const match = serverText.match(/APP_VERSION\s*=\s*'([^']+)'/);
|
||||||
|
const serverVersion = match?.[1] || null;
|
||||||
|
const localVersion = typeof APP_VERSION !== 'undefined' ? APP_VERSION : '0';
|
||||||
|
|
||||||
|
// SW update anstoßen
|
||||||
const reg = await navigator.serviceWorker.getRegistration();
|
const reg = await navigator.serviceWorker.getRegistration();
|
||||||
await reg?.update();
|
await reg?.update();
|
||||||
if (reg?.waiting) {
|
|
||||||
// Neuer SW wartet — sofort aktivieren
|
if (serverVersion && serverVersion !== localVersion) {
|
||||||
|
// Neuere Version verfügbar — Seite neu laden
|
||||||
|
if (reg?.waiting) reg.waiting.postMessage({ type: 'SKIP_WAITING' });
|
||||||
|
UI.toast.info(`Update auf v${serverVersion} verfügbar — Seite wird neu geladen…`);
|
||||||
|
setTimeout(() => location.reload(), 1500);
|
||||||
|
} else if (reg?.waiting) {
|
||||||
reg.waiting.postMessage({ type: 'SKIP_WAITING' });
|
reg.waiting.postMessage({ type: 'SKIP_WAITING' });
|
||||||
UI.toast.success('Update wird installiert…');
|
UI.toast.success('Update wird installiert…');
|
||||||
} else {
|
} else {
|
||||||
UI.toast.success('Ban Yaro ist aktuell — v' + (typeof APP_VERSION !== 'undefined' ? APP_VERSION : '1.0.0') + '.');
|
UI.toast.success(`Ban Yaro ist aktuell — v${localVersion}`);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
UI.toast.error('Update-Prüfung fehlgeschlagen.');
|
UI.toast.error('Update-Prüfung fehlgeschlagen.');
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v560';
|
const CACHE_VERSION = 'by-v561';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue