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:
parent
0c0daaad6b
commit
53fcb61933
6 changed files with 222 additions and 14 deletions
|
|
@ -58,7 +58,8 @@ window.Page_map = (() => {
|
|||
zuechter: [],
|
||||
};
|
||||
|
||||
const VISIBLE_KEY = 'by_map_visible_v1';
|
||||
const VISIBLE_KEY = 'by_map_visible_v1';
|
||||
const _MAP_POI_KEY = 'by_map_pois_cache';
|
||||
|
||||
let _visible = {};
|
||||
// Gespeicherten Zustand laden, Fallback: alles sichtbar
|
||||
|
|
@ -1217,9 +1218,41 @@ window.Page_map = (() => {
|
|||
API.breeder.mapMarkers(),
|
||||
]);
|
||||
|
||||
if (places.status === 'fulfilled') _addPlaces(places.value);
|
||||
if (poisonList.status === 'fulfilled') _addPoison(poisonList.value);
|
||||
if (breederList.status === 'fulfilled') _addBreeders(breederList.value);
|
||||
const allFailed = [places, poisonList, breederList].every(r => r.status === 'rejected');
|
||||
if (allFailed) {
|
||||
try {
|
||||
const raw = localStorage.getItem(_MAP_POI_KEY);
|
||||
if (raw) {
|
||||
const cached = JSON.parse(raw);
|
||||
_addPlaces(cached.places || []);
|
||||
_addPoison(cached.poison || []);
|
||||
_addBreeders(cached.breeders || []);
|
||||
UI.toast.info('Offline — Karte zeigt gecachte Kacheln. POI-Daten eventuell veraltet.');
|
||||
_scheduleOsmLoad();
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const placesVal = places.status === 'fulfilled' ? places.value : [];
|
||||
const poisonVal = poisonList.status === 'fulfilled' ? poisonList.value : [];
|
||||
const breederVal = breederList.status === 'fulfilled' ? breederList.value : [];
|
||||
|
||||
if (places.status === 'fulfilled') _addPlaces(placesVal);
|
||||
if (poisonList.status === 'fulfilled') _addPoison(poisonVal);
|
||||
if (breederList.status === 'fulfilled') _addBreeders(breederVal);
|
||||
|
||||
if (places.status === 'fulfilled' || poisonList.status === 'fulfilled' || breederList.status === 'fulfilled') {
|
||||
try {
|
||||
localStorage.setItem(_MAP_POI_KEY, JSON.stringify({
|
||||
ts: Date.now(),
|
||||
places: placesVal,
|
||||
poison: poisonVal,
|
||||
breeders: breederVal,
|
||||
}));
|
||||
} catch {}
|
||||
}
|
||||
|
||||
_scheduleOsmLoad();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue