Skip to content

Commit

Permalink
[Issue-1469] Can not reset account/eraser all when close app
Browse files Browse the repository at this point in the history
  • Loading branch information
dominhquang committed Sep 28, 2024
1 parent d7ff775 commit d4602f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/screens/MasterPassword/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -216,7 +216,6 @@ const Login: React.FC<LoginProps> = ({ navigation }) => {
const _setLoading = resetAll ? setEraseAllLoading : setAccLoading;
_setLoading(true);
setTimeout(() => {
_setLoading(false);
resetWallet({
resetAll: resetAll,
})
Expand All @@ -227,18 +226,18 @@ const Login: React.FC<LoginProps> = ({ navigation }) => {
})
.catch((e: Error) => {
toast.show(e.message, { type: 'danger' });
_setLoading(false);
})
.finally(() => {
_setLoading(false);
setModalVisible(false);
if (resetAll) {
resetPinCode();
} else {
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);
};
Expand Down
16 changes: 9 additions & 7 deletions src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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';
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit d4602f1

Please sign in to comment.