Fix: Offline-Score Cache-Detection robust, SW by-v1084
Bug: APP_VER war in app.js nur lokale const, nicht window.APP_VER → offline-indicator.js öffnete Cache 'by-v0-static' statt 'by-v1083-static' → fast alle Stufen blieben grau. Fixes: - app.js: window.APP_VER + window.APP_VERSION explizit setzen - offline-indicator.js: _staticCache() Helper findet den aktuellen Static-Cache per Regex /^by-v\d+-static$/ — versions-unabhängig - Step 1 (App-Shell) prüft jetzt korrekt auf design-system.css UND app.js im Static-Cache, nicht mehr caches.match() mit URL
This commit is contained in:
parent
b9fe5b5bc3
commit
95dccd03be
5 changed files with 30 additions and 19 deletions
|
|
@ -410,7 +410,7 @@ async def serve_media(path: str, request: _Request):
|
|||
raise _HE(404, "Nicht gefunden.")
|
||||
return _media_response(filepath)
|
||||
|
||||
APP_VER = "1083" # muss mit APP_VER in app.js übereinstimmen
|
||||
APP_VER = "1084" # muss mit APP_VER in app.js übereinstimmen
|
||||
|
||||
@app.get("/.well-known/assetlinks.json")
|
||||
async def assetlinks():
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@
|
|||
</script>
|
||||
|
||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1083">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1083">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1083">
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1084">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1084">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1084">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -625,11 +625,11 @@
|
|||
<div id="modal-container"></div>
|
||||
|
||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||
<script src="/js/api.js?v=1083"></script>
|
||||
<script src="/js/ui.js?v=1083"></script>
|
||||
<script src="/js/app.js?v=1083"></script>
|
||||
<script src="/js/worlds.js?v=1083"></script>
|
||||
<script src="/js/offline-indicator.js?v=1083"></script>
|
||||
<script src="/js/api.js?v=1084"></script>
|
||||
<script src="/js/ui.js?v=1084"></script>
|
||||
<script src="/js/app.js?v=1084"></script>
|
||||
<script src="/js/worlds.js?v=1084"></script>
|
||||
<script src="/js/offline-indicator.js?v=1084"></script>
|
||||
|
||||
<!-- Feature-Seiten werden lazy geladen -->
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '1083'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '1084'; // ← 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;
|
||||
const IS_STAGING = location.hostname === 'staging.banyaro.app';
|
||||
// Cache-Bust-Parameter nach Update-Reload sofort entfernen.
|
||||
// Flag MUSS vor replaceState gesetzt werden — index.html liest es danach.
|
||||
|
|
|
|||
|
|
@ -8,27 +8,36 @@
|
|||
window.OfflineIndicator = (() => {
|
||||
'use strict';
|
||||
|
||||
// Cache-Namen — müssen mit sw.js übereinstimmen
|
||||
const CACHE_STATIC = `by-v${(window.APP_VER || '0')}-static`;
|
||||
// Cache-Namen dynamisch finden — robust gegen Versions-Updates
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1';
|
||||
const CACHE_API = 'ban-yaro-api-v1';
|
||||
const TILE_MIN = 50;
|
||||
|
||||
async function _staticCache() {
|
||||
const names = await caches.keys();
|
||||
const found = names.find(n => /^by-v\d+-static$/.test(n));
|
||||
return found ? await caches.open(found) : null;
|
||||
}
|
||||
|
||||
const CHECKS = [
|
||||
{ step: 1, title: 'App-Grundgerüst',
|
||||
detail: 'CSS, Layout und Hauptmodule — die Basis',
|
||||
probe: async () => (await caches.match('/css/design-system.css?v=' + window.APP_VER)) != null
|
||||
|| (await caches.match('/css/design-system.css')) != null },
|
||||
probe: async () => {
|
||||
const c = await _staticCache();
|
||||
if (!c) return false;
|
||||
const urls = (await c.keys()).map(r => r.url);
|
||||
return urls.some(u => u.includes('/css/design-system.css'))
|
||||
&& urls.some(u => u.includes('/js/app.js'));
|
||||
} },
|
||||
|
||||
{ step: 2, title: 'Wichtige Seiten',
|
||||
detail: 'Tagebuch, Karte, Gassi, Erste Hilfe',
|
||||
probe: async () => {
|
||||
const c = await caches.open(CACHE_STATIC).catch(() => null);
|
||||
const c = await _staticCache();
|
||||
if (!c) return false;
|
||||
const must = ['diary.js','map.js','walks.js','erste-hilfe.js'];
|
||||
const keys = await c.keys();
|
||||
const have = keys.map(r => r.url);
|
||||
return must.every(name => have.some(u => u.includes('/js/pages/' + name)));
|
||||
const urls = (await c.keys()).map(r => r.url);
|
||||
return must.every(name => urls.some(u => u.includes('/js/pages/' + name)));
|
||||
} },
|
||||
|
||||
{ step: 3, title: 'Hund- und Tagebuchdaten',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
============================================================ */
|
||||
|
||||
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
||||
const VER = '1083';
|
||||
const VER = '1084';
|
||||
const CACHE_VERSION = `by-v${VER}`;
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue