This commit is contained in:
MEGASOL\simon.adams
2025-08-30 20:17:22 +02:00
parent b714134f2e
commit 6a4e7fdb65
2 changed files with 27 additions and 2 deletions

View File

@@ -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.

View File

@@ -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;