Skip to content

Commit 91162ef

Browse files
authored
fix: do not sync when there are no channels (#2117)
1 parent 5a9d416 commit 91162ef

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

examples/TypeScriptMessaging/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ EXTERNAL SOURCES:
708708
:path: "../node_modules/react-native/ReactCommon/yoga"
709709

710710
SPEC CHECKSUMS:
711-
boost: a7c83b31436843459a1961bfd74b96033dc77234
711+
boost: 57d2868c099736d80fcd648bf211b4431e51a558
712712
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
713713
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
714714
FBLazyVector: a89a0525bc7ca174675045c2b492b5280d5a2470
@@ -729,7 +729,7 @@ SPEC CHECKSUMS:
729729
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
730730
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
731731
PromisesSwift: cf9eb58666a43bbe007302226e510b16c1e10959
732-
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
732+
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
733733
RCTRequired: 5a4a30ac20c86eeadd6844a9328f78d4168cf9b2
734734
RCTTypeSafety: 279fc5861a89f0f37db3a585f27f971485b4b734
735735
React: 88307a9be3bd0e71a6822271cf28b84a587fb97f

package/src/store/apis/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export * from './upsertAppSettings';
1717
export * from './upsertChannelData';
1818
export * from './upsertChannels';
1919
export * from './upsertCidsForQuery';
20-
export * from './upsertLastSyncedAt';
20+
export * from './upsertUserSyncStatus';
2121
export * from './upsertMembers';
2222
export * from './upsertMessages';
2323
export * from './upsertReads';

package/src/store/apis/upsertLastSyncedAt.ts renamed to package/src/store/apis/upsertUserSyncStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { QuickSqliteClient } from '../QuickSqliteClient';
22
import { createUpsertQuery } from '../sqlite-utils/createUpsertQuery';
33

4-
export const upsertLastSyncedAt = ({
4+
export const upsertUserSyncStatus = ({
55
currentUserId,
66
lastSyncedAt,
77
}: {

package/src/utils/DBSyncManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { AxiosError } from 'axios';
22
import type { APIErrorResponse, StreamChat } from 'stream-chat';
33

44
import { handleEventToSyncDB } from '../components/Chat/hooks/handleEventToSyncDB';
5-
import { getAllChannelIds, getLastSyncedAt, upsertLastSyncedAt } from '../store/apis';
5+
import { getAllChannelIds, getLastSyncedAt, upsertUserSyncStatus } from '../store/apis';
66

77
import { addPendingTask } from '../store/apis/addPendingTask';
88

@@ -11,6 +11,7 @@ import { getPendingTasks } from '../store/apis/getPendingTasks';
1111
import { QuickSqliteClient } from '../store/QuickSqliteClient';
1212
import type { PendingTask, PreparedQueries } from '../store/types';
1313
import type { DefaultStreamChatGenerics } from '../types/types';
14+
1415
/**
1516
* DBSyncManager has the responsibility to sync the channel states
1617
* within local database whenever possible.
@@ -95,6 +96,8 @@ export class DBSyncManager {
9596
currentUserId: this.client.user.id,
9697
});
9798
const cids = getAllChannelIds();
99+
// If there are no channels, then there is no need to sync.
100+
if (cids.length === 0) return;
98101

99102
if (lastSyncedAt) {
100103
try {
@@ -113,7 +116,7 @@ export class DBSyncManager {
113116
QuickSqliteClient.resetDB();
114117
}
115118
}
116-
upsertLastSyncedAt({
119+
upsertUserSyncStatus({
117120
currentUserId: this.client.user.id,
118121
lastSyncedAt: new Date().toString(),
119122
});

0 commit comments

Comments
 (0)