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

@ -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.');
}