@@ -9,14 +9,14 @@ import { SupabaseConnector } from '../supabase/SupabaseConnector';
99import { KVStorage } from '../storage/KVStorage' ;
1010import { PhotoAttachmentQueue } from './PhotoAttachmentQueue' ;
1111import { type AttachmentRecord } from '@powersync/attachments' ;
12+ import { AppConfig } from '../supabase/AppConfig' ;
1213
1314export class System {
1415 kvStorage : KVStorage ;
1516 storage : SupabaseStorageAdapter ;
1617 supabaseConnector : SupabaseConnector ;
1718 powersync : AbstractPowerSyncDatabase ;
18-
19- attachmentQueue : PhotoAttachmentQueue ;
19+ attachmentQueue : PhotoAttachmentQueue | undefined = undefined ;
2020
2121 constructor ( ) {
2222 this . kvStorage = new KVStorage ( ) ;
@@ -29,26 +29,30 @@ export class System {
2929 this . storage = this . supabaseConnector . storage ;
3030 this . powersync = factory . getInstance ( ) ;
3131
32- this . attachmentQueue = new PhotoAttachmentQueue ( {
33- powersync : this . powersync ,
34- storage : this . storage ,
35- // Use this to handle download errors where you can use the attachment
36- // and/or the exception to decide if you want to retry the download
37- onDownloadError : async ( attachment : AttachmentRecord , exception : any ) => {
38- if ( exception . toString ( ) === 'StorageApiError: Object not found' ) {
39- return { retry : false } ;
32+ if ( AppConfig . supabaseBucket ) {
33+ this . attachmentQueue = new PhotoAttachmentQueue ( {
34+ powersync : this . powersync ,
35+ storage : this . storage ,
36+ // Use this to handle download errors where you can use the attachment
37+ // and/or the exception to decide if you want to retry the download
38+ onDownloadError : async ( attachment : AttachmentRecord , exception : any ) => {
39+ if ( exception . toString ( ) === 'StorageApiError: Object not found' ) {
40+ return { retry : false } ;
41+ }
42+
43+ return { retry : true } ;
4044 }
41-
42- return { retry : true } ;
43- }
44- } ) ;
45+ } ) ;
46+ }
4547 }
4648
4749 async init ( ) {
4850 await this . powersync . init ( ) ;
4951 await this . powersync . connect ( this . supabaseConnector ) ;
5052
51- await this . attachmentQueue . init ( ) ;
53+ if ( this . attachmentQueue ) {
54+ await this . attachmentQueue . init ( ) ;
55+ }
5256 }
5357}
5458
0 commit comments