From d4602f1f007ab258b8d9f2f3d42866f472744b18 Mon Sep 17 00:00:00 2001 From: dominhquang Date: Sat, 28 Sep 2024 09:36:18 +0700 Subject: [PATCH] [Issue-1469] Can not reset account/eraser all when close app --- src/screens/MasterPassword/Login/index.tsx | 9 ++++----- src/utils/storage.ts | 16 +++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/screens/MasterPassword/Login/index.tsx b/src/screens/MasterPassword/Login/index.tsx index c30e3b47c..3ffe04aa0 100644 --- a/src/screens/MasterPassword/Login/index.tsx +++ b/src/screens/MasterPassword/Login/index.tsx @@ -35,7 +35,7 @@ import { import { updateFaceIdEnable, updateUseBiometric } from 'stores/MobileSettings'; import { FORCE_HIDDEN_EVENT } from 'components/design-system-ui/modal/ModalBaseV2'; import MigrateToKeychainPasswordModal from '../MigrateToKeychainPasswordModal'; -import { backupStorageData, mmkvStore } from 'utils/storage'; +import { clearBackupData, mmkvStore } from 'utils/storage'; import { setBuildNumber } from 'stores/AppVersion'; import { LockTimeout } from 'stores/types'; import useConfirmationsInfo from 'hooks/screen/Confirmation/useConfirmationsInfo'; @@ -216,7 +216,6 @@ const Login: React.FC = ({ navigation }) => { const _setLoading = resetAll ? setEraseAllLoading : setAccLoading; _setLoading(true); setTimeout(() => { - _setLoading(false); resetWallet({ resetAll: resetAll, }) @@ -227,9 +226,9 @@ const Login: React.FC = ({ navigation }) => { }) .catch((e: Error) => { toast.show(e.message, { type: 'danger' }); + _setLoading(false); }) .finally(() => { - _setLoading(false); setModalVisible(false); if (resetAll) { resetPinCode(); @@ -237,8 +236,8 @@ const Login: React.FC = ({ navigation }) => { dispatch(updateUseBiometric(false)); resetKeychainPassword(); } - // BACKUP-003: Back up local storage after reset account - backupStorageData(true, false); + // Clear backed up data after reset account + clearBackupData(); }); }, 300); }; diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 3c2b7182c..56e66169b 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -158,13 +158,6 @@ export const triggerBackupOnInit = () => { }; export const restoreStorageData = () => { - // Todo: Consider to remove this condition - // if (!isIOS17) { - // // Restore empty storage - // mobileRestore({}).catch(console.error); - // return; - // } - const indexedDB = mmkvStore.getString('backup-indexedDB'); const localstorage = mmkvStore.getString('backup-localstorage'); mobileRestore({ indexedDB, storage: localstorage }) @@ -174,6 +167,13 @@ export const restoreStorageData = () => { }) .catch(e => console.debug('** Restore storage data error:', e)); }; +export const clearBackupData = () => { + mmkvStore.set('backup-indexedDB', ''); + mmkvStore.set('backup-localstorage', ''); + mmkvStore.set('webRunnerLastBackupTime', ''); + mmkvStore.set('webRunnerLastBackupTimestamp', ''); + mmkvStore.set('app-is-setup', ''); +}; // MKT Campaign flags for iOS 17 when reset data happen const bannerSlugKey = 'bannerSlugs'; @@ -209,6 +209,8 @@ export const getHideBanner = (key: string) => { return campaignId as string[] | undefined; }; + +// Dev mode flag export const devMode = (isDevMode: boolean) => { mmkvStore.set('DEV_MODE', isDevMode); };