Fix: Ernährung Hund-spezifisch, Erinnerungen in Settings, Übung des Tages per Hund (SW by-v872)
- ernaehrung.js: onDogChange setzt activeTab zurück, Hund klar sichtbar
- settings.js: Erinnerungen-Sektion lädt verstorbene Hunde + öffnet Gedenkseite
- dogs.py: GET /dogs/verstorben Endpoint (korrekte Route-Reihenfolge vor /{dog_id})
- dogs.py: Übung des Tages filtert jetzt nach dog_id statt user_id (sitzt-Übungen korrekt ausgeschlossen)
- Routen zeigen verstorbene Hunde korrekt als Teilnehmer (route_dogs ohne verstorben-Filter)
This commit is contained in:
parent
265d3d4fe2
commit
1ce802c8dc
8 changed files with 1106 additions and 28 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Offline-Cache + Push Notifications + Tile-Cache
|
||||
============================================================ */
|
||||
|
||||
const CACHE_VERSION = 'by-v856';
|
||||
const CACHE_VERSION = 'by-v872';
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache
|
||||
|
|
@ -123,6 +123,7 @@ const _CACHEABLE_GET = [
|
|||
/^\/api\/dogs\/\d+\/health(?!\/ki-)/, // ki-berichte + ki-zusammenfassung nie cachen
|
||||
/^\/api\/training\/exercises/,
|
||||
/^\/api\/training\/progress/,
|
||||
/^\/api\/training\/plan-progress/,
|
||||
/^\/api\/wiki\/rassen/,
|
||||
/^\/api\/dogs\/\d+\/diary\/stats/,
|
||||
// Drei Welten — offline-fähig
|
||||
|
|
@ -136,14 +137,18 @@ function _isCacheableGet(pathname) {
|
|||
}
|
||||
|
||||
// Cache-TTL: stabile Daten länger, dynamische kürzer
|
||||
const _STABLE_GET = [/^\/api\/training\/exercises/, /^\/api\/wiki\/rassen/];
|
||||
const _STABLE_GET = [/^\/api\/training\/exercises/, /^\/api\/wiki\/rassen/];
|
||||
const _SHORT_GET = [/^\/api\/training\/progress/, /^\/api\/training\/plan-progress/];
|
||||
const _TTL_STABLE = 60 * 60 * 1000; // 1 Stunde
|
||||
const _TTL_SHORT = 30 * 1000; // 30 Sekunden (Fortschritte, hund-spezifisch)
|
||||
const _TTL_DEFAULT = 5 * 60 * 1000; // 5 Minuten
|
||||
|
||||
const _cacheTs = new Map(); // pathname → timestamp (in-memory, ok bei SW-Neustart)
|
||||
|
||||
function _cacheTTL(pathname) {
|
||||
return _STABLE_GET.some(re => re.test(pathname)) ? _TTL_STABLE : _TTL_DEFAULT;
|
||||
if (_STABLE_GET.some(re => re.test(pathname))) return _TTL_STABLE;
|
||||
if (_SHORT_GET.some(re => re.test(pathname))) return _TTL_SHORT;
|
||||
return _TTL_DEFAULT;
|
||||
}
|
||||
function _cacheStale(pathname) {
|
||||
const ts = _cacheTs.get(pathname);
|
||||
|
|
@ -359,6 +364,12 @@ self.addEventListener('message', event => {
|
|||
self.skipWaiting();
|
||||
return;
|
||||
}
|
||||
if (event.data?.type === 'INVALIDATE_CACHE') {
|
||||
// Cache-Timestamps für angegebene Pfade zurücksetzen → nächster Request geht ans Netz
|
||||
const paths = event.data.paths || [];
|
||||
paths.forEach(p => _cacheTs.delete(p));
|
||||
return;
|
||||
}
|
||||
if (event.data?.type === 'PROCESS_QUEUE') {
|
||||
event.waitUntil(_processQueue());
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue