Skip to content

Commit 4946f37

Browse files
committed
refactor: implement watchAttachments as a class property
1 parent 9812964 commit 4946f37

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

packages/common/src/attachments/AttachmentQueue.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ export class AttachmentQueue {
3535
/** Adapter for remote file storage operations */
3636
remoteStorage: RemoteStorageAdapter;
3737

38-
/** @deprecated Directory path for storing attachments */
39-
attachmentsDirectory?: string;
38+
/**
39+
* Callback function to watch for changes in attachment references in your data model.
40+
*
41+
* This should be implemented by the user of AttachmentQueue to monitor changes in your application's
42+
* data that reference attachments. When attachments are added, removed, or modified,
43+
* this callback should trigger the onUpdate function with the current set of attachments.
44+
*/
45+
watchAttachments: (
46+
onUpdate: (attachment: WatchedAttachmentItem[]) => Promise<void>,
47+
signal: AbortSignal
48+
) => void;
4049

4150
/** Name of the database table storing attachment records */
4251
tableName?: string;
@@ -123,20 +132,6 @@ export class AttachmentQueue {
123132
this.logger = logger ?? db.logger;
124133
}
125134

126-
/**
127-
* Callback function to watch for changes in attachment references in your data model.
128-
*
129-
* This method should be implemented to monitor changes in your application's
130-
* data that reference attachments. When attachments are added, removed, or modified,
131-
* this callback should trigger the onUpdate function with the current set of attachments.
132-
*
133-
* @param onUpdate - Callback to invoke when attachment references change
134-
* @throws Error indicating this method must be implemented by the user
135-
*/
136-
watchAttachments(onUpdate: (attachment: WatchedAttachmentItem[]) => Promise<void>, signal: AbortSignal): void {
137-
throw new Error('watchAttachments should be implemented by the user of AttachmentQueue');
138-
}
139-
140135
/**
141136
* Generates a new attachment ID using a SQLite UUID function.
142137
*

0 commit comments

Comments
 (0)