Fix: Update-Button leert SW-Cache vor Reload, Fallback-Text für Desktop (Cmd+Shift+R) (SW by-v736)

This commit is contained in:
rene 2026-05-06 18:50:54 +02:00
parent 98ac7fcb79
commit 11067d9ef8
4 changed files with 11 additions and 13 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '735'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '736'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VERSION = '1.4.0'; // ← semantische Version, wird bei make release gesetzt
const IS_STAGING = location.hostname === 'staging.banyaro.app';
@ -978,8 +978,8 @@ const App = (() => {
<strong>1.</strong> Drücke lange auf das App-Icon am Homescreen<br>
<strong>2.</strong> Wähle App entfernen" (nur das Symbol, keine Daten)<br>
<strong>3.</strong> Öffne banyaro.app in Safari und füge die App erneut hinzu`
: `Falls die App nicht aktualisiert:<br>
Öffne banyaro.app im Browser und füge sie erneut zum Startbildschirm hinzu.`}
: `Falls die Seite noch die alte Version zeigt:<br>
Drücke <strong>Cmd+Shift+R</strong> (Mac) bzw. <strong>Ctrl+Shift+R</strong> (Windows/Android Chrome) für einen harten Reload.`}
</div>
`;
@ -991,18 +991,16 @@ const App = (() => {
const btn = banner.querySelector('#upd-btn-reload');
btn.textContent = 'Lädt…';
btn.disabled = true;
// SW-Update anstoßen
sessionStorage.setItem('by_update_reload', APP_VER);
try {
// SW aktivieren + alle Caches leeren für sauberen Reload
const reg = await navigator.serviceWorker?.getRegistration();
if (reg?.waiting) reg.waiting.postMessage({ type: 'SKIP_WAITING' });
await reg?.update();
const keys = await caches.keys();
await Promise.all(keys.map(k => caches.delete(k)));
} catch { /* ignorieren */ }
// Kurz warten, dann hard reload
setTimeout(() => {
location.reload();
}, 800);
// Nach Reload: wenn Version immer noch alt, iOS-Hinweis anzeigen
sessionStorage.setItem('by_update_reload', APP_VER);
setTimeout(() => location.reload(), 600);
});
}