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(); +}