File tree Expand file tree Collapse file tree 6 files changed +10
-9
lines changed
supabase-todolist-drift/lib/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 @@ -68,7 +68,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
68
68
}
69
69
70
70
@override
71
- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
71
+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
72
72
log.info ('Watching photos in $todosTable ...' );
73
73
return db.watch ('''
74
74
SELECT photo_id FROM $todosTable
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
68
68
}
69
69
70
70
@override
71
- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
71
+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
72
72
log.info ('Watching photos in $todosTable ...' );
73
73
return db.watch ('''
74
74
SELECT photo_id FROM $todosTable
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
62
62
// This watcher will handle adding items to the queue based on
63
63
// a users table element receiving a photoId
64
64
@override
65
- StreamSubscription<void> watchIds({String fileExtension = 'jpg' }) {
65
+ StreamSubscription<void> watchIds({String? fileExtension}) {
66
66
return db.watch('''
67
67
SELECT photo_id FROM users
68
68
WHERE photo_id IS NOT NULL
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class PhotoAttachmentQueue extends AbstractAttachmentQueue {
46
46
}
47
47
48
48
@override
49
- StreamSubscription <void > watchIds ({String fileExtension = 'jpg' }) {
49
+ StreamSubscription <void > watchIds ({String ? fileExtension}) {
50
50
return db.watch ('''
51
51
SELECT photo_id FROM users
52
52
WHERE photo_id IS NOT NULL
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ abstract class AbstractAttachmentQueue {
59
59
60
60
/// Create watcher to get list of ID's from a table to be used for syncing in the attachment queue.
61
61
/// 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});
63
63
64
64
/// Create a function to save files using the attachment queue
65
65
Future <Attachment > saveFile (String fileId, int size);
@@ -82,7 +82,7 @@ abstract class AbstractAttachmentQueue {
82
82
}
83
83
}
84
84
85
- watchIds ();
85
+ watchIds (fileExtension : 'jpg' );
86
86
syncingService.watchAttachments ();
87
87
syncingService.startPeriodicSync (intervalInMinutes);
88
88
Original file line number Diff line number Diff line change @@ -165,11 +165,12 @@ class SyncingService {
165
165
}
166
166
167
167
/// 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 {
169
169
List <Attachment > attachments = List .empty (growable: true );
170
170
171
171
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);
173
174
File file = File (path);
174
175
bool fileExists = await file.exists ();
175
176
@@ -180,7 +181,7 @@ class SyncingService {
180
181
log.info ('Adding $id to queue' );
181
182
attachments.add (Attachment (
182
183
id: id,
183
- filename: '$ id .$ fileExtension ' ,
184
+ filename: filename ,
184
185
state: AttachmentState .queuedDownload.index));
185
186
}
186
187
You can’t perform that action at this time.
0 commit comments