Fix: Wetter-Chip ohne farbigen Rand, Update-Prüfung nutzt APP_VER+API+location.replace('/') (SW by-v769)
This commit is contained in:
parent
4a6c056742
commit
572fbf642f
6 changed files with 14 additions and 17 deletions
|
|
@ -753,27 +753,24 @@ window.Page_settings = (() => {
|
|||
}
|
||||
if (btn) btn.textContent = 'Prüfe…';
|
||||
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';
|
||||
// Versionsnummer direkt vom API-Endpunkt holen
|
||||
const r = await fetch('/api/version', { cache: 'no-store' });
|
||||
const { version: serverVersion } = await r.json();
|
||||
const localVersion = typeof APP_VER !== 'undefined' ? APP_VER : '0';
|
||||
|
||||
// SW update anstoßen
|
||||
const reg = await navigator.serviceWorker.getRegistration();
|
||||
await reg?.update();
|
||||
reg?.update().catch(() => {}); // kein await — kann hängen
|
||||
|
||||
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);
|
||||
UI.toast.info(`Update auf v${serverVersion} — Seite wird neu geladen…`);
|
||||
setTimeout(() => location.replace('/'), 1500);
|
||||
} else if (reg?.waiting) {
|
||||
reg.waiting.postMessage({ type: 'SKIP_WAITING' });
|
||||
UI.toast.success('Update wird installiert…');
|
||||
setTimeout(() => location.replace('/'), 1500);
|
||||
} else {
|
||||
UI.toast.success(`Ban Yaro ist aktuell — v${localVersion}`);
|
||||
UI.toast.success(`Ban Yaro ist aktuell — Build ${localVersion}`);
|
||||
}
|
||||
} catch {
|
||||
UI.toast.error('Update-Prüfung fehlgeschlagen.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue