From 2e4cde4b6e3c5cc5f67c572992fd03819707b20b Mon Sep 17 00:00:00 2001 From: ralksta Date: Fri, 29 May 2026 17:47:08 +0200 Subject: [PATCH] fix: clear album cache on admin save so changes appear immediately When saving gallery/settings via admin, the config cache was invalidated but the Immich album cache (which stores resolved title overrides and descriptions) was not cleared. This meant changes only appeared after the TTL expired or a manual 'Reload' click. Now both gallery and settings saves also call immich.invalidateAll() to flush the album cache, making changes visible on next page load. --- app/api/admin/gallery/route.ts | 2 ++ app/api/admin/settings/route.ts | 2 ++ lib/immich.ts | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/api/admin/gallery/route.ts b/app/api/admin/gallery/route.ts index afbae2f..f35a927 100644 --- a/app/api/admin/gallery/route.ts +++ b/app/api/admin/gallery/route.ts @@ -2,6 +2,7 @@ import { NextResponse } from 'next/server'; import { isAdminAuthenticated, isAdminEnabled } from '@/lib/admin/auth'; import { readGalleryYaml, writeGalleryYaml } from '@/lib/admin/yaml-service'; import { invalidateConfigCache } from '@/lib/config'; +import { immich } from '@/lib/immich'; import type { GalleryYaml } from '@/lib/config/schema'; /** GET: Read current gallery.yaml config. */ @@ -40,6 +41,7 @@ export async function PUT(request: Request) { try { await writeGalleryYaml(gallery); invalidateConfigCache(); + immich.invalidateAll(); return NextResponse.json({ success: true, message: 'Saved successfully. Backup of previous version created.' }); } catch (err) { console.error('[Admin] Failed to write gallery.yaml:', err); diff --git a/app/api/admin/settings/route.ts b/app/api/admin/settings/route.ts index 0562859..bffef3c 100644 --- a/app/api/admin/settings/route.ts +++ b/app/api/admin/settings/route.ts @@ -2,6 +2,7 @@ import { NextResponse } from 'next/server'; import { isAdminAuthenticated, isAdminEnabled } from '@/lib/admin/auth'; import { readSettingsYaml, writeSettingsYaml } from '@/lib/admin/yaml-service'; import { invalidateConfigCache } from '@/lib/config'; +import { immich } from '@/lib/immich'; import type { SettingsYaml } from '@/lib/config/schema'; /** GET: Read current settings.yaml config. */ @@ -36,6 +37,7 @@ export async function PUT(request: Request) { try { await writeSettingsYaml(settings); invalidateConfigCache(); + immich.invalidateAll(); return NextResponse.json({ success: true, message: 'Saved successfully. Backup of previous version created.' }); } catch (err) { console.error('[Admin] Failed to write settings.yaml:', err); diff --git a/lib/immich.ts b/lib/immich.ts index 9004932..49a6fc0 100644 --- a/lib/immich.ts +++ b/lib/immich.ts @@ -434,7 +434,8 @@ class ImmichClient { */ invalidateAll(): void { cache.clear(); - console.log('[Immich] 🔄 Full cache cleared via webhook'); + this.hasLoggedAlbums = false; + console.log('[Immich] 🔄 Full cache cleared'); } /**