@@ -198,65 +198,20 @@ export const usePaginatedChannels = ({
198198 const sortStr = useMemo ( ( ) => JSON . stringify ( sort ) , [ sort ] ) ;
199199
200200 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-
232201 let listener : ReturnType < typeof client . offlineDb . syncManager . onSyncStatusChange > ;
233202 if ( enableOfflineSupport ) {
234203 // Any time DB is synced, we need to update the UI with local DB channels first,
235204 // and then call queryChannels to ensure any new channels are added to UI.
236205 listener = client . offlineDb . syncManager . onSyncStatusChange ( async ( syncStatus ) => {
237206 if ( syncStatus ) {
238- // const loadingChannelsSucceeded = await loadOfflineChannels();
239- // if (loadingChannelsSucceeded) {
240207 await reloadList ( ) ;
241- // setForceUpdate((u) => u + 1);
242- // }
243208 }
244209 } ) ;
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- // });
256210 } else {
257211 listener = client . on ( 'connection.changed' , async ( event ) => {
258212 if ( event . online ) {
259213 await refreshList ( ) ;
214+ // FIXME: I think this cna be removed, but have to check
260215 setForceUpdate ( ( u ) => u + 1 ) ;
261216 }
262217 } ) ;
@@ -265,7 +220,7 @@ export const usePaginatedChannels = ({
265220
266221 return ( ) => listener ?. unsubscribe ?.( ) ;
267222 // eslint-disable-next-line react-hooks/exhaustive-deps
268- } , [ client , filterStr , sortStr , channelManager ] ) ;
223+ } , [ filterStr , sortStr , channelManager ] ) ;
269224
270225 return {
271226 channelListInitialized,
0 commit comments