Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-1469] Can not reset account/eraser all when close app #1812

Open
wants to merge 1 commit into
base: upgrade-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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
Loading