diff --git a/backend/main.py b/backend/main.py index 0ede6c1..ad1a5ca 100644 --- a/backend/main.py +++ b/backend/main.py @@ -406,7 +406,7 @@ async def serve_media(path: str, request: _Request): raise _HE(404, "Nicht gefunden.") return _media_response(filepath) -APP_VER = "927" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "928" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/routes/dogs.py b/backend/routes/dogs.py index cc86caf..405856f 100644 --- a/backend/routes/dogs.py +++ b/backend/routes/dogs.py @@ -191,23 +191,24 @@ async def get_welcome_dashboard(dog_id: int, user=Depends(get_current_user)): raise HTTPException(404, "Hund nicht gefunden.") # Hintergrundfoto: Querformat-Bilder bevorzugt, tagesweise rotierend + # user_id-Filter als zweite Sicherungsebene (dog_id-Ownership bereits oben geprüft) photos = conn.execute( """SELECT dm.url FROM diary_media dm JOIN diary d ON d.id = dm.diary_id - WHERE d.dog_id=? AND dm.media_type='image' + WHERE d.dog_id=? AND d.user_id=? AND dm.media_type='image' AND dm.img_width IS NOT NULL AND dm.img_width > dm.img_height ORDER BY d.datum DESC, d.id DESC, dm.id ASC""", - (dog_id,) + (dog_id, user["id"]) ).fetchall() # Fallback: Bilder ohne Dimensionsdaten (vor dem Backfill hochgeladen) if not photos: photos = conn.execute( """SELECT dm.url FROM diary_media dm JOIN diary d ON d.id = dm.diary_id - WHERE d.dog_id=? AND dm.media_type='image' + WHERE d.dog_id=? AND d.user_id=? AND dm.media_type='image' AND dm.img_width IS NULL ORDER BY d.datum DESC, d.id DESC, dm.id ASC""", - (dog_id,) + (dog_id, user["id"]) ).fetchall() random_photo = None if photos: diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 6366a57..ba4c022 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '927'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '928'; // ← 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 diff --git a/backend/static/js/pages/dog-profile.js b/backend/static/js/pages/dog-profile.js index 9399085..8e18db5 100644 --- a/backend/static/js/pages/dog-profile.js +++ b/backend/static/js/pages/dog-profile.js @@ -1388,6 +1388,9 @@ window.Page_dog_profile = (() => { // Dog Switcher in Header + Sidebar aktualisieren App.renderDogSwitcher?.(); + // Welten neu laden damit HUND-Welt den neuen Hund zeigt + window.Worlds?.refresh(_appState); + await _render(); }); }); diff --git a/backend/static/js/worlds.js b/backend/static/js/worlds.js index e032542..b640775 100644 --- a/backend/static/js/worlds.js +++ b/backend/static/js/worlds.js @@ -924,7 +924,8 @@ window.Worlds = (() => { async function _loadDailyImage(dog) { if (!dog) return null; - const todayKey = 'bg3_' + new Date().toISOString().slice(0, 10); + const userId = _state?.user?.id || 'anon'; + const todayKey = `bg3_${userId}_` + new Date().toISOString().slice(0, 10); const cached = _wLoad(todayKey); if (cached?.data) return cached.data; try { @@ -1689,6 +1690,17 @@ window.Worlds = (() => { return String(s).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } - return { init, show, hide, navigateTo, openConfig: _openConfigModal, get _visible() { return _visible; } }; + function refresh(appState) { + if (appState) _state = appState; + localStorage.removeItem('w3_dogs'); + _bgUrl = null; + if (_visible) { + if (_cur === 0) _renderJetzt(); + else if (_cur === 1) _renderHund(); + else _renderWelt(); + } + } + + return { init, show, hide, navigateTo, refresh, openConfig: _openConfigModal, get _visible() { return _visible; } }; })(); diff --git a/backend/static/sw.js b/backend/static/sw.js index aa529d6..1f31d7d 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v927'; +const CACHE_VERSION = 'by-v928'; 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