Skip to content
Source
Sign inSign up

composerAttachmentPreviewRetention.ts

19 lines752 Bytes

1import type { FileBackedComposerAttachment } from "./composerImages";
2import { retainComposerAttachmentFile } from "./composerAttachmentFiles";
3​
4/** State owns files but cannot be imported here; it registers cleanup when draft owners load. */
5type UnusedAttachmentHandler = (attachment: FileBackedComposerAttachment) => void;
6​
7let onAttachmentUnused: UnusedAttachmentHandler | null = null;
8​
9export function registerComposerAttachmentUnusedHandler(handler: UnusedAttachmentHandler): void {
10 onAttachmentUnused = handler;
12​
13export function retainComposerAttachmentFileForPreview(
14 attachment: FileBackedComposerAttachment,
15): () => void {
16 return retainComposerAttachmentFile(attachment.fileUri, () => {
17 onAttachmentUnused?.(attachment);
18 });