From 6a4e7fdb652a03a42dd89df46eed3469fd12e237 Mon Sep 17 00:00:00 2001 From: "MEGASOL\\simon.adams" Date: Sat, 30 Aug 2025 20:17:22 +0200 Subject: [PATCH] . --- app/app.py | 15 +++++++++++++++ frontend/app.js | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index 2fe1acd..eb61ac4 100644 --- a/app/app.py +++ b/app/app.py @@ -56,6 +56,11 @@ SETTINGS: Settings = load_settings() # Album cache ALBUM_ID: Optional[str] = None +def reset_album_cache() -> None: + """Invalidate the cached Immich album id so next use re-resolves it.""" + global ALBUM_ID + ALBUM_ID = None + # ---------- DB (local dedupe cache) ---------- def db_init() -> None: @@ -330,6 +335,10 @@ async def ws_endpoint(ws: WebSocket) -> None: session_id = data.get("session_id") or "default" except Exception: session_id = "default" + # If this is the first socket for a (possibly new) session, reset album cache + # so a freshly opened page can rotate the drop album by renaming the old one. + if session_id not in hub.sessions: + reset_album_cache() await hub.connect(session_id, ws) # keepalive to avoid proxy idle timeouts @@ -435,6 +444,12 @@ async def api_upload( return await do_upload() +@app.post("/api/album/reset") +async def api_album_reset() -> dict: + """Explicit trigger from the UI to clear cached album id.""" + reset_album_cache() + return {"ok": True} + """ Note: Do not run this module directly. Use `python main.py` from project root, which starts `uvicorn app.app:app` with reload. diff --git a/frontend/app.js b/frontend/app.js index 28e202b..d6e6d69 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -253,8 +253,18 @@ if (!isTouch) { } // --- Clear buttons --- -btnClearFinished.onclick = ()=>{ items = items.filter(i => !['done','duplicate'].includes(i.status)); render(); }; -btnClearAll.onclick = ()=>{ items = []; render(); }; +btnClearFinished.onclick = ()=>{ + items = items.filter(i => !['done','duplicate'].includes(i.status)); + render(); + // also tell server to refresh album cache so a renamed album triggers a new one + fetch('/api/album/reset', { method: 'POST' }).catch(()=>{}); +}; +btnClearAll.onclick = ()=>{ + items = []; + render(); + // also reset album cache server-side + fetch('/api/album/reset', { method: 'POST' }).catch(()=>{}); +}; // --- Dark mode toggle --- btnTheme.onclick = toggleDarkMode;