Fix: Offline-Indicator Cache-Namen + Step-5-Check, SW by-v1078
- CACHE_API hieß bei mir 'by-api', tatsächlich aber 'ban-yaro-api-v1' → korrigiert, sonst hätte step 3+5 nie grün werden können - Step 5 prüfte auf gecachte Diary-Foto-Previews — die werden vom SW aber gar nicht gecacht (nur API-Routen sind in _CACHEABLE_GET). Stattdessen jetzt 'Training & Wissen' (training/exercises + wiki/rassen) — ist im SW-Cache abgedeckt und passt zur WELT-Welt - _fetchMissing für Step 5 entsprechend angepasst
This commit is contained in:
parent
8097d21605
commit
776641fa65
5 changed files with 20 additions and 28 deletions
|
|
@ -10,7 +10,7 @@ window.OfflineIndicator = (() => {
|
|||
// Cache-Namen — müssen mit sw.js übereinstimmen
|
||||
const CACHE_STATIC = `by-v${(window.APP_VER || '0')}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1';
|
||||
const CACHE_API = 'by-api';
|
||||
const CACHE_API = 'ban-yaro-api-v1';
|
||||
const TILE_MIN = 50; // Mindest-Tiles für Stufe 4
|
||||
|
||||
// 5 Offline-Bereitschafts-Checks, in Reihenfolge der Pfoten-Stufen
|
||||
|
|
@ -51,13 +51,14 @@ window.OfflineIndicator = (() => {
|
|||
return keys.length >= TILE_MIN;
|
||||
} },
|
||||
|
||||
{ step: 5, title: 'Tagebuch-Fotos',
|
||||
detail: 'Vorschau-Bilder der letzten Einträge',
|
||||
{ step: 5, title: 'Training & Wissen',
|
||||
detail: 'Übungen, Wiki-Rassen, Wetter — Welt-Inhalte',
|
||||
probe: async () => {
|
||||
const c = await caches.open(CACHE_API).catch(() => null);
|
||||
if (!c) return false;
|
||||
const keys = await c.keys();
|
||||
return keys.some(r => r.url.includes('/data/diary/') && r.url.includes('_preview'));
|
||||
const urls = (await c.keys()).map(r => r.url);
|
||||
return urls.some(u => u.includes('/api/training/exercises'))
|
||||
&& urls.some(u => u.includes('/api/wiki/rassen'));
|
||||
} },
|
||||
];
|
||||
|
||||
|
|
@ -180,18 +181,9 @@ window.OfflineIndicator = (() => {
|
|||
}
|
||||
}
|
||||
} else if (m.step === 5) {
|
||||
const dogId = window._appState?.activeDog?.id;
|
||||
if (dogId) {
|
||||
try {
|
||||
const entries = await fetch(`/api/dogs/${dogId}/diary?limit=10`).then(r => r.json());
|
||||
(entries || []).slice(0, 10).forEach(e => {
|
||||
if (e.cover_url) tasks.push(fetch(e.cover_url).catch(() => {}));
|
||||
(e.media_items || []).slice(0, 3).forEach(m => {
|
||||
if (m.url) tasks.push(fetch(m.url).catch(() => {}));
|
||||
});
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
tasks.push(fetch('/api/training/exercises').catch(() => {}));
|
||||
tasks.push(fetch('/api/wiki/rassen?limit=50').catch(() => {}));
|
||||
tasks.push(fetch('/api/weather').catch(() => {}));
|
||||
}
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue