fix: clear ocr and asset cache when edits are applied (#25533)

* fix: clear ocr and asset cache when edits are applied

* use event manager

* fix: undefined check
This commit is contained in:
Brandon Wees
2026-01-26 12:48:34 -06:00
committed by GitHub
parent 97220102e4
commit b5c3d87290
3 changed files with 21 additions and 7 deletions
@@ -1,3 +1,4 @@
import { eventManager } from '$lib/managers/event-manager.svelte';
import { getAssetInfo, getAssetOcr, type AssetOcrResponseDto, type AssetResponseDto } from '@immich/sdk';
const defaultSerializer = <K>(params: K) => JSON.stringify(params);
@@ -35,6 +36,13 @@ class AssetCacheManager {
#assetCache = new AsyncCache<AssetResponseDto>();
#ocrCache = new AsyncCache<AssetOcrResponseDto[]>();
constructor() {
eventManager.on('AssetEditsApplied', () => {
this.#assetCache.clear();
this.#ocrCache.clear();
});
}
async getAsset(assetIdentifier: { key?: string; slug?: string; id: string }, updateCache = true) {
return this.#assetCache.getOrFetch(assetIdentifier, getAssetInfo, defaultSerializer, updateCache);
}