@@ -198,65 +198,20 @@ export const usePaginatedChannels = ({
198
198
const sortStr = useMemo ( ( ) => JSON . stringify ( sort ) , [ sort ] ) ;
199
199
200
200
useEffect ( ( ) => {
201
- const loadOfflineChannels = async ( ) => {
202
- if ( ! client ?. user ?. id ) {
203
- return ;
204
- }
205
-
206
- try {
207
- const channelsFromDB = await getChannelsForFilterSort ( {
208
- currentUserId : client . user . id ,
209
- filters,
210
- sort,
211
- } ) ;
212
-
213
- if ( channelsFromDB ) {
214
- const offlineChannels = client . hydrateActiveChannels ( channelsFromDB , {
215
- offlineMode : true ,
216
- skipInitialization : [ ] , // passing empty array will clear out the existing messages from channel state, this removes the possibility of duplicate messages
217
- } ) ;
218
-
219
- channelManager . setChannels ( offlineChannels ) ;
220
- setStaticChannelsActive ( true ) ;
221
- }
222
- } catch ( e ) {
223
- console . warn ( 'Failed to get channels from database: ' , e ) ;
224
- return false ;
225
- }
226
-
227
- setActiveQueryType ( null ) ;
228
-
229
- return true ;
230
- } ;
231
-
232
201
let listener : ReturnType < typeof client . offlineDb . syncManager . onSyncStatusChange > ;
233
202
if ( enableOfflineSupport ) {
234
203
// Any time DB is synced, we need to update the UI with local DB channels first,
235
204
// and then call queryChannels to ensure any new channels are added to UI.
236
205
listener = client . offlineDb . syncManager . onSyncStatusChange ( async ( syncStatus ) => {
237
206
if ( syncStatus ) {
238
- // const loadingChannelsSucceeded = await loadOfflineChannels();
239
- // if (loadingChannelsSucceeded) {
240
207
await reloadList ( ) ;
241
- // setForceUpdate((u) => u + 1);
242
- // }
243
208
}
244
209
} ) ;
245
- // On start, load the channels from local db.
246
- // loadOfflineChannels().then((success) => {
247
- // // If db is already synced (sync api and pending api calls), then
248
- // // right away call queryChannels.
249
- // if (success) {
250
- // const dbSyncStatus = DBSyncManager.getSyncStatus();
251
- // if (dbSyncStatus) {
252
- // reloadList();
253
- // }
254
- // }
255
- // });
256
210
} else {
257
211
listener = client . on ( 'connection.changed' , async ( event ) => {
258
212
if ( event . online ) {
259
213
await refreshList ( ) ;
214
+ // FIXME: I think this cna be removed, but have to check
260
215
setForceUpdate ( ( u ) => u + 1 ) ;
261
216
}
262
217
} ) ;
@@ -265,7 +220,7 @@ export const usePaginatedChannels = ({
265
220
266
221
return ( ) => listener ?. unsubscribe ?.( ) ;
267
222
// eslint-disable-next-line react-hooks/exhaustive-deps
268
- } , [ client , filterStr , sortStr , channelManager ] ) ;
223
+ } , [ filterStr , sortStr , channelManager ] ) ;
269
224
270
225
return {
271
226
channelListInitialized,
0 commit comments