Skip to content

Commit beecac0

Browse files
committed
fix(notification): wait for sync to complete
1 parent 2905ee5 commit beecac0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/features/app_notification/container/useContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
encryptedAccessCodeState,
77
encryptedMasterKeyState,
88
featureFlagsState,
9+
isAppDataSyncingState,
910
speakersKeyState,
1011
userIDState,
1112
} from '@states/app';
@@ -68,11 +69,13 @@ const useContainer = () => {
6869
const accountType = useAtomValue(accountTypeState);
6970
const userID = useAtomValue(userIDState);
7071
const FEATURE_FLAGS = useAtomValue(featureFlagsState);
72+
const isAppSyncing = useAtomValue(isAppDataSyncingState);
7173

7274
const { data, isFetching } = useQuery({
7375
enabled:
7476
userID?.length > 0 &&
7577
accountType === 'vip' &&
78+
!isAppSyncing &&
7679
isElder &&
7780
congAccountConnected,
7881
queryKey: ['congregation_updates'],

src/wrapper/web_worker/useWebWorker.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { useEffect, useState } from 'react';
22
import { useLocation } from 'react-router';
3-
import { useAtomValue } from 'jotai';
4-
import { setIsAppDataSyncing, setLastAppDataSync } from '@services/states/app';
3+
import { useAtomValue, useSetAtom } from 'jotai';
4+
import { setLastAppDataSync } from '@services/states/app';
55
import { isTest, LANGUAGE_LIST } from '@constants/index';
6-
import { congAccountConnectedState, isOnlineState } from '@states/app';
6+
import {
7+
congAccountConnectedState,
8+
isAppDataSyncingState,
9+
isOnlineState,
10+
} from '@states/app';
711
import {
812
backupAutoState,
913
backupIntervalState,
@@ -27,6 +31,8 @@ const useWebWorker = () => {
2731

2832
const { isMeetingEditor } = useCurrentUser();
2933

34+
const setIsAppDataSyncing = useSetAtom(isAppDataSyncingState);
35+
3036
const isOnline = useAtomValue(isOnlineState);
3137
const isConnected = useAtomValue(congAccountConnectedState);
3238
const backupAuto = useAtomValue(backupAutoState);
@@ -79,7 +85,7 @@ const useWebWorker = () => {
7985
}
8086
};
8187
}
82-
}, [isMeetingEditor, sourceLang]);
88+
}, [isMeetingEditor, sourceLang, setIsAppDataSyncing]);
8389

8490
useEffect(() => {
8591
const runBackupTimer = setInterval(async () => {

0 commit comments

Comments
 (0)