Offline-Fallbacks für diary, poison, map + SW-Erweiterung

- sw.js: /api/places, /api/breeder/map-markers, /api/gassi-zeiten in _CACHEABLE_GET; /api/lost/report und /api/walks in _QUEUEABLE
- diary.js: localStorage-Cache pro Hund, Fallback bei Offline mit Toast
- poison.js: localStorage-Cache, Fallback bei Offline mit Toast (sicherheitsrelevant)
- map.js: POI-Cache (places/poison/breeders) in localStorage, Offline-Toast + Fallback auf gecachte Daten
This commit is contained in:
rene 2026-05-15 17:02:26 +02:00
parent 0c0daaad6b
commit 53fcb61933
6 changed files with 222 additions and 14 deletions

View file

@ -5,6 +5,8 @@
window.Page_poison = (() => {
const _CACHE_KEY = 'by_poison_cache';
// ----------------------------------------------------------
// MODUL-STATE
// ----------------------------------------------------------
@ -171,6 +173,7 @@ window.Page_poison = (() => {
try {
_reports = await API.poison.listNearby(_userPos.lat, _userPos.lon, 10000);
try { localStorage.setItem(_CACHE_KEY, JSON.stringify({ ts: Date.now(), data: _reports })); } catch {}
_renderMarkers();
_renderList();
_updateBadge(_reports.length);
@ -180,6 +183,18 @@ window.Page_poison = (() => {
: 'Keine aktiven Giftköder-Meldungen in deiner Nähe (10 km Radius).';
}
} catch {
try {
const raw = localStorage.getItem(_CACHE_KEY);
if (raw) {
_reports = JSON.parse(raw).data || [];
_renderMarkers();
_renderList();
_updateBadge(_reports.length);
if (infoEl) infoEl.textContent = `${_reports.length} gecachte Meldung${_reports.length !== 1 ? 'en' : ''} (Offline)`;
UI.toast.info('Offline — zeige zuletzt geladene Daten.');
return;
}
} catch {}
UI.toast.error('Meldungen konnten nicht geladen werden.');
}
}