Skip to content

Commit

Permalink
Prevent backup prompt from firing on import (#6364)
Browse files Browse the repository at this point in the history
* remove backup prompt from importing flow as it runs in the walletReady flow now

* fix potential race condition
  • Loading branch information
walmat authored Dec 20, 2024
1 parent 94b8a96 commit 0f4f232
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
10 changes: 4 additions & 6 deletions src/handlers/walletReadyEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const delay = (ms: number) =>
});

const promptForBackupOnceReadyOrNotAvailable = async (): Promise<boolean> => {
const { status } = backupsStore.getState();
if (LoadingStates.includes(status)) {
let { status } = backupsStore.getState();
while (LoadingStates.includes(status)) {
await delay(1000);
return promptForBackupOnceReadyOrNotAvailable();
status = backupsStore.getState().status;
}

logger.debug(`[walletReadyEvents]: BackupSheet: showing backup now sheet for selected wallet`);
Expand All @@ -47,9 +47,7 @@ export const runWalletBackupStatusChecks = async (): Promise<boolean> => {
const { selected } = store.getState().wallets;
if (!selected || IS_TEST) return false;

const selectedWalletNeedsBackedUp =
!selected.backedUp && !selected.damaged && selected.type !== WalletTypes.readOnly && selected.type !== WalletTypes.bluetooth;
if (selectedWalletNeedsBackedUp) {
if (!selected.backedUp && !selected.damaged && selected.type !== WalletTypes.readOnly && selected.type !== WalletTypes.bluetooth) {
logger.debug('[walletReadyEvents]: Selected wallet is not backed up, prompting backup sheet');
return promptForBackupOnceReadyOrNotAvailable();
}
Expand Down
18 changes: 0 additions & 18 deletions src/hooks/useImportingWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,24 +339,6 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
});
}, 1_000);

setTimeout(() => {
// If it's not read only or hardware, show the backup sheet
if (
!(
isENSAddressFormat(input) ||
isUnstoppableAddressFormat(input) ||
isValidAddress(input) ||
isValidBluetoothDeviceId(input)
)
) {
if (!IS_TEST) {
Navigation.handleAction(Routes.BACKUP_SHEET, {
step: WalletBackupStepTypes.backup_prompt,
});
}
}
}, 1000);

analytics.track('Imported seed phrase', {
isWalletEthZero,
});
Expand Down

0 comments on commit 0f4f232

Please sign in to comment.