Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/channel_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,14 @@ export class ChannelManager extends WithSubscriptions {
`Maximum number of retries reached in queryChannels. Last error message is: ${err}`,
);

this.state.partialNext({ error: wrappedError });
this.state.partialNext({
error: wrappedError,
pagination: {
...this.state.getLatestValue().pagination,
isLoading: false,
isLoadingNext: false,
},
});
return;
}

Expand Down Expand Up @@ -444,7 +451,11 @@ export class ChannelManager extends WithSubscriptions {
this.client.logger('error', (error as Error).message);
this.state.next((currentState) => ({
...currentState,
pagination: { ...currentState.pagination, isLoadingNext: false },
pagination: {
...currentState.pagination,
isLoadingNext: false,
isLoading: false,
},
}));
throw error;
}
Expand Down
5 changes: 5 additions & 0 deletions src/offline-support/offline_sync_manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ExecuteBatchDBQueriesType } from './types';
import type { StreamChat } from '../client';
import type { AbstractOfflineDB } from './offline_support_api';
import { AxiosError } from 'axios';

/**
* Manages synchronization between the local offline database and the Stream backend.
Expand Down Expand Up @@ -176,6 +177,10 @@ export class OfflineDBSyncManager {
console.log('An error has occurred while syncing the DB.', e);
// Error will be raised by the sync API if there are too many events.
// In that case reset the entire DB and start fresh.
// We avoid resetting the DB if the error is due to timeout.
if (e instanceof AxiosError && e.response?.data?.code === 23) {
return;
}
await this.offlineDb.resetDB();
}
};
Expand Down