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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user