From 415fa10ed0b9b91c56072d4f6e01aa789b6a5a19 Mon Sep 17 00:00:00 2001 From: byGalax Date: Thu, 14 May 2026 00:16:49 +0200 Subject: [PATCH] feat(mobile): in-memory attachment cache by handle id --- apps/mobile/lib/attachmentCache.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 apps/mobile/lib/attachmentCache.ts diff --git a/apps/mobile/lib/attachmentCache.ts b/apps/mobile/lib/attachmentCache.ts new file mode 100644 index 0000000..b7450bc --- /dev/null +++ b/apps/mobile/lib/attachmentCache.ts @@ -0,0 +1,18 @@ +// Module-level memo of decrypted-attachment data URLs by handle id. +// Survives screen unmounts (e.g. user pops in and out of a conversation) +// but evicts on app restart — good enough for Phase 2; an LRU + disk +// cache is a later polish. + +const cache = new Map(); + +export function getCachedAttachment(id: string): string | undefined { + return cache.get(id); +} + +export function setCachedAttachment(id: string, dataUrl: string): void { + cache.set(id, dataUrl); +} + +export function clearAttachmentCache(): void { + cache.clear(); +}