Fix: SW-Cache welcome-dashboard nach Foto-Upload löschen (SW by-v935)

Root cause: /api/dogs/{id}/welcome-dashboard ist SW-gecacht.
Nach Foto-Upload lieferte SW alten Response mit alter random_photo.url.
Fix: API.swCacheDelete() + localStorage-Key nach Upload invalidieren.
This commit is contained in:
rene 2026-05-14 12:18:48 +02:00
parent aa379d8e08
commit fbb070032a
5 changed files with 17 additions and 8 deletions

View file

@ -800,9 +800,17 @@ const API = (() => {
get(`/osm/pois?type=${type}&south=${south}&west=${west}&north=${north}&east=${east}&fast=true`),
};
// SW-Cache-Einträge für eine URL löschen (z.B. nach Foto-Upload)
async function swCacheDelete(path) {
try {
const c = await caches.open('ban-yaro-api-v1');
await c.delete(new Request(path));
} catch {}
}
// Öffentliche API
return {
get, post, put, patch, del, upload,
get, post, put, patch, del, upload, swCacheDelete,
auth, dogs, diary, health, tieraerzte, healthDocs, poison,
places, routes, walks, events, sitting, forum, lost, knigge, weather, push,
friends, chat, webcal, importData, sharing, widget, notifications, services, ratings, sittingAccess, training, notes,

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '934'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '935'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VERSION = '1.5.1'; // ← semantische Version, wird bei make release gesetzt
const IS_STAGING = location.hostname === 'staging.banyaro.app';
// Cache-Bust-Parameter nach Update-Reload sofort entfernen

View file

@ -769,9 +769,10 @@ window.Page_dog_profile = (() => {
await API.dogs.updatePhotoPosition(dog.id, 1.0, 0.0, 0.0);
_appState.activeDog = { ..._appState.activeDog, foto_url: result.foto_url, foto_zoom: 1, foto_offset_x: 0, foto_offset_y: 0 };
_appState.dogs = _appState.dogs.map(d => d.id === dog.id ? _appState.activeDog : d);
// Hintergrund-Cache invalidieren
// localStorage + SW-Cache invalidieren
const userId2 = _appState.user?.id || 'anon';
localStorage.removeItem(`w3_bg3_${userId2}_` + new Date().toISOString().slice(0, 10));
API.swCacheDelete(`/api/dogs/${dog.id}/welcome-dashboard`);
UI.modal.close();
App.renderDogSwitcher?.();
window.Worlds?.refresh(_appState);
@ -1386,10 +1387,10 @@ window.Page_dog_profile = (() => {
saved.foto_url = result.foto_url;
_appState.activeDog = { ...saved };
_appState.dogs = _appState.dogs.map(d => d.id === saved.id ? _appState.activeDog : d);
// Hintergrund-Cache invalidieren damit Welten das neue Foto zeigen
// localStorage + SW-Cache invalidieren damit Welten das neue Foto zeigen
const userId = _appState.user?.id || 'anon';
const todayKey = `w3_bg3_${userId}_` + new Date().toISOString().slice(0, 10);
localStorage.removeItem(todayKey);
localStorage.removeItem(`w3_bg3_${userId}_` + new Date().toISOString().slice(0, 10));
API.swCacheDelete(`/api/dogs/${saved.id}/welcome-dashboard`);
} catch {
UI.toast.warning('Profil gespeichert, Foto konnte nicht hochgeladen werden.');
}

View file

@ -3,7 +3,7 @@
Offline-Cache + Push Notifications + Tile-Cache
============================================================ */
const CACHE_VERSION = 'by-v934';
const CACHE_VERSION = 'by-v935';
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