@@ -268,9 +268,6 @@ export class ChannelManager {
268
268
269
269
const queryChannelsRequest = async ( retryCount = 0 ) => {
270
270
try {
271
- if ( retryCount <= 2 ) {
272
- throw new Error ( 'Failing intentionally' ) ;
273
- }
274
271
const channels = await this . client . queryChannels (
275
272
filters ,
276
273
sort ,
@@ -332,46 +329,42 @@ export class ChannelManager {
332
329
error : undefined ,
333
330
} ) ) ;
334
331
335
- if (
336
- this . client . offlineDb ?. getChannelsForQuery &&
337
- this . client . user ?. id &&
338
- ! initialized
339
- ) {
340
- const channelsFromDB = await this . client . offlineDb . getChannelsForQuery ( {
341
- userId : this . client . user . id ,
342
- filters,
343
- sort,
344
- } ) ;
345
-
346
- console . log ( 'CHANNELS FROM DB PRE: ' , channelsFromDB ) ;
347
-
348
- if ( channelsFromDB ) {
349
- console . log ( 'GOT CHANNELS FROM DB !' , initialized , isLoading ) ;
350
- const offlineChannels = this . client . hydrateActiveChannels ( channelsFromDB , {
351
- offlineMode : true ,
352
- skipInitialization : [ ] , // passing empty array will clear out the existing messages from channel state, this removes the possibility of duplicate messages
332
+ if ( this . client . offlineDb ?. getChannelsForQuery && this . client . user ?. id ) {
333
+ if ( ! initialized ) {
334
+ const channelsFromDB = await this . client . offlineDb . getChannelsForQuery ( {
335
+ userId : this . client . user . id ,
336
+ filters,
337
+ sort,
353
338
} ) ;
354
339
355
- this . state . partialNext ( { channels : offlineChannels } ) ;
340
+ console . log ( 'CHANNELS FROM DB PRE: ' , channelsFromDB ) ;
356
341
357
- console . log ( 'IS IT SYNCED: ' , this . client . offlineDb . syncManager . syncStatus ) ;
342
+ if ( channelsFromDB ) {
343
+ console . log ( 'GOT CHANNELS FROM DB !' , initialized , isLoading ) ;
344
+ const offlineChannels = this . client . hydrateActiveChannels ( channelsFromDB , {
345
+ offlineMode : true ,
346
+ skipInitialization : [ ] , // passing empty array will clear out the existing messages from channel state, this removes the possibility of duplicate messages
347
+ } ) ;
358
348
359
- if ( ! this . client . offlineDb . syncManager . syncStatus ) {
360
- this . client . offlineDb . syncManager . scheduleSyncStatusChangeCallback (
361
- async ( syncStatus ) => {
362
- console . log ( 'WILL TRY NOW VAL: ' , syncStatus ) ;
363
- if ( syncStatus ) {
364
- await queryChannelsRequest ( ) ;
365
- }
366
- } ,
367
- ) ;
368
- return ;
349
+ this . state . partialNext ( { channels : offlineChannels } ) ;
369
350
}
370
351
}
371
- await queryChannelsRequest ( ) ;
372
- } else {
373
- await queryChannelsRequest ( ) ;
352
+ console . log ( 'IS IT SYNCED: ' , this . client . offlineDb . syncManager . syncStatus ) ;
353
+
354
+ if ( ! this . client . offlineDb . syncManager . syncStatus ) {
355
+ this . client . offlineDb . syncManager . scheduleSyncStatusChangeCallback (
356
+ async ( syncStatus ) => {
357
+ console . log ( 'WILL TRY NOW VAL: ' , syncStatus ) ;
358
+ if ( syncStatus ) {
359
+ await queryChannelsRequest ( ) ;
360
+ }
361
+ } ,
362
+ ) ;
363
+ return ;
364
+ }
365
+ // await queryChannelsRequest();
374
366
}
367
+ await queryChannelsRequest ( ) ;
375
368
} catch ( error ) {
376
369
this . client . logger ( 'error' , ( error as Error ) . message ) ;
377
370
this . state . next ( ( currentState ) => ( {
0 commit comments