Skip to content

Commit d8d4ad9

Browse files
committed
Add updateHook to save file
1 parent 6840fb0 commit d8d4ad9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/attachments/src/AttachmentQueue.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,15 @@ export class AttachmentQueue {
178178
fileExtension,
179179
mediaType,
180180
metaData,
181-
id
181+
id,
182+
updateHook
182183
}: {
183184
data: ArrayBuffer | Blob | string;
184185
fileExtension: string;
185186
mediaType?: string;
186187
metaData?: string;
187188
id?: string;
189+
updateHook?: (transaction: Transaction, attachment: AttachmentRecord) => void;
188190
}): Promise<AttachmentRecord> {
189191
const resolvedId = id ?? (await this.context.db.get<{ id: string }>('SELECT uuid() as id')).id;
190192
const filename = `${resolvedId}.${fileExtension}`;
@@ -204,6 +206,7 @@ export class AttachmentQueue {
204206
};
205207

206208
await this.context.db.writeTransaction(async (tx) => {
209+
updateHook?.(tx, attachment);
207210
this.context.upsertAttachment(attachment, tx);
208211
});
209212

0 commit comments

Comments
 (0)