Fix: /force-update reload-Hänger + Cooldown persistent, SW by-v1106
User-Report: 'Leckerlis'-Screen verschwindet nicht mehr. Bug: Vorige Version nutzte 'await Promise.all([sw-unregister, caches.delete])' VOR dem Reload. Auf iOS-PWA können diese Promises gelegentlich nie resolven → Reload kommt nie. Fix /force-update: - Cleanup-Tasks fire-and-forget (kein await, kein Promise.all) - Sofort-Reload nach 150ms (kein await-Block) - Fallback 1: Nach 3s erscheint 'App neu starten'-Button für manuellen Tap - Fallback 2: Nach 6s automatisch location.href mit ?hard=1 Fix app.js Cooldown: - localStorage statt sessionStorage — überlebt PWA-App-Close - 10 Min statt 5 Min Cooldown (großzügiger Spielraum bei Update-Wellen)
This commit is contained in:
parent
b0ae71ba69
commit
c8ef4939f1
6 changed files with 52 additions and 42 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '1105'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '1106'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
|
||||
window.APP_VERSION = APP_VERSION;
|
||||
|
|
@ -129,17 +129,19 @@ const App = (() => {
|
|||
function navigate(pageId, pushHistory = true, params = {}) {
|
||||
if (!pages[pageId]) return;
|
||||
// Neue Version erkannt → nur aktualisieren wenn kein Bearbeitungsfenster offen ist
|
||||
// UND wenn nicht erst kürzlich force-update lief (Cooldown 5 Min) — verhindert Loop
|
||||
// bei mehreren schnellen Deploys oder iOS-PWA-Cache-Quirks.
|
||||
// UND wenn nicht erst kürzlich force-update lief (Cooldown 10 Min) — verhindert Loop
|
||||
// bei mehreren schnellen Deploys oder iOS-PWA-Cache-Quirks. localStorage überlebt
|
||||
// App-Restarts (sessionStorage wäre bei PWA-Standalone-close weg).
|
||||
if (window._byUpdatePending) {
|
||||
const modalOpen = document.querySelector('#modal-container .modal-overlay') !== null;
|
||||
const lastForce = parseInt(sessionStorage.getItem('by_last_force_update') || '0', 10);
|
||||
const cooldownActive = (Date.now() - lastForce) < 5 * 60 * 1000;
|
||||
let lastForce = 0;
|
||||
try { lastForce = parseInt(localStorage.getItem('by_last_force_update') || '0', 10); } catch {}
|
||||
const cooldownActive = (Date.now() - lastForce) < 10 * 60 * 1000;
|
||||
if (!modalOpen && !cooldownActive) {
|
||||
window._byUpdatePending = false;
|
||||
sessionStorage.setItem('by_updated_to', window._byNewVersion || '');
|
||||
sessionStorage.setItem('by_update_target', pageId);
|
||||
sessionStorage.setItem('by_last_force_update', String(Date.now()));
|
||||
try { localStorage.setItem('by_last_force_update', String(Date.now())); } catch {}
|
||||
location.href = '/force-update';
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue