@@ -9,14 +9,14 @@ import { SupabaseConnector } from '../supabase/SupabaseConnector';
9
9
import { KVStorage } from '../storage/KVStorage' ;
10
10
import { PhotoAttachmentQueue } from './PhotoAttachmentQueue' ;
11
11
import { type AttachmentRecord } from '@powersync/attachments' ;
12
+ import { AppConfig } from '../supabase/AppConfig' ;
12
13
13
14
export class System {
14
15
kvStorage : KVStorage ;
15
16
storage : SupabaseStorageAdapter ;
16
17
supabaseConnector : SupabaseConnector ;
17
18
powersync : AbstractPowerSyncDatabase ;
18
-
19
- attachmentQueue : PhotoAttachmentQueue ;
19
+ attachmentQueue : PhotoAttachmentQueue | undefined = undefined ;
20
20
21
21
constructor ( ) {
22
22
this . kvStorage = new KVStorage ( ) ;
@@ -29,26 +29,30 @@ export class System {
29
29
this . storage = this . supabaseConnector . storage ;
30
30
this . powersync = factory . getInstance ( ) ;
31
31
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 } ;
40
44
}
41
-
42
- return { retry : true } ;
43
- }
44
- } ) ;
45
+ } ) ;
46
+ }
45
47
}
46
48
47
49
async init ( ) {
48
50
await this . powersync . init ( ) ;
49
51
await this . powersync . connect ( this . supabaseConnector ) ;
50
52
51
- await this . attachmentQueue . init ( ) ;
53
+ if ( this . attachmentQueue ) {
54
+ await this . attachmentQueue . init ( ) ;
55
+ }
52
56
}
53
57
}
54
58
0 commit comments