File tree Expand file tree Collapse file tree 6 files changed +10
-9
lines changed
supabase-todolist-drift/lib/powersync/attachments
supabase-todolist/lib/attachments
packages/powersync_attachments_helper Expand file tree Collapse file tree 6 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
7878 }
7979
8080 @override
81- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
81+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
8282 log.info ('Watching photos in $todosTable ...' );
8383 return db.watch ('''
8484 SELECT photo_id FROM $todosTable
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
6868 }
6969
7070 @override
71- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
71+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
7272 log.info ('Watching photos in $todosTable ...' );
7373 return db.watch ('''
7474 SELECT photo_id FROM $todosTable
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
6262 // This watcher will handle adding items to the queue based on
6363 // a users table element receiving a photoId
6464 @override
65- StreamSubscription<void> watchIds({String fileExtension = 'jpg' }) {
65+ StreamSubscription<void> watchIds({String? fileExtension}) {
6666 return db.watch('''
6767 SELECT photo_id FROM users
6868 WHERE photo_id IS NOT NULL
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
4646 }
4747
4848 @override
49- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
49+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
5050 return db.watch ('''
5151 SELECT photo_id FROM users
5252 WHERE photo_id IS NOT NULL
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ abstract class AbstractAttachmentQueue {
5959
6060 /// Create watcher to get list of ID's from a table to be used for syncing in the attachment queue.
6161 /// Set the file extension if you are using a different file type
62- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' });
62+ StreamSubscription <void > watchIds ({String ? fileExtension});
6363
6464 /// Create a function to save files using the attachment queue
6565 Future <Attachment > saveFile (String fileId, int size);
@@ -82,7 +82,7 @@ abstract class AbstractAttachmentQueue {
8282 }
8383 }
8484
85- watchIds ();
85+ watchIds (fileExtension : 'jpg' );
8686 syncingService.watchAttachments ();
8787 syncingService.startPeriodicSync (intervalInMinutes);
8888
Original file line number Diff line number Diff line change @@ -165,11 +165,12 @@ class SyncingService {
165165 }
166166
167167 /// Process ID's to be included in the attachment queue.
168- Future <void > processIds (List <String > ids, String fileExtension) async {
168+ Future <void > processIds (List <String > ids, String ? fileExtension) async {
169169 List <Attachment > attachments = List .empty (growable: true );
170170
171171 for (String id in ids) {
172- String path = await getLocalUri ('$id .$fileExtension ' );
172+ String filename = fileExtension != null ? '$id .$fileExtension ' : id;
173+ String path = await getLocalUri (filename);
173174 File file = File (path);
174175 bool fileExists = await file.exists ();
175176
@@ -180,7 +181,7 @@ class SyncingService {
180181 log.info ('Adding $id to queue' );
181182 attachments.add (Attachment (
182183 id: id,
183- filename: '$ id .$ fileExtension ' ,
184+ filename: filename ,
184185 state: AttachmentState .queuedDownload.index));
185186 }
186187
You can’t perform that action at this time.
0 commit comments