Files
ChatApp/apps/mobile/lib/attachmentCache.ts
T

19 lines
551 B
TypeScript

// 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<string, string>();
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();
}