Skip to content

Commit

Permalink
Fix Android import first wallet navigation stack (#6393)
Browse files Browse the repository at this point in the history
* fixes android not replacing route on first wallet import

* cleanup console logs

* Update src/hooks/useImportingWallet.ts

* fix bad rebase
  • Loading branch information
walmat authored Jan 15, 2025
1 parent 852ecaf commit 6c94cd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 19 additions & 14 deletions src/hooks/useImportingWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { PROFILES, useExperimentalFlag } from '@/config';
import { fetchReverseRecord } from '@/handlers/ens';
import { getProvider, isValidBluetoothDeviceId, resolveUnstoppableDomain } from '@/handlers/web3';
import { isENSAddressFormat, isUnstoppableAddressFormat, isValidWallet } from '@/helpers/validators';
import WalletBackupStepTypes from '@/helpers/walletBackupStepTypes';
import { walletInit } from '@/model/wallet';
import { Navigation, useNavigation } from '@/navigation';
import { walletsLoadState } from '@/redux/wallets';
Expand All @@ -30,8 +29,11 @@ import { handleReviewPromptAction } from '@/utils/reviewAlert';
import { ReviewPromptAction } from '@/storage/schema';
import { ChainId } from '@/state/backendNetworks/types';
import { backupsStore } from '@/state/backups/backups';
import { walletLoadingStore } from '@/state/walletLoading/walletLoading';
import { WalletLoadingStates } from '@/helpers/walletLoadingStates';
import { IS_TEST } from '@/env';
import walletBackupTypes from '@/helpers/walletBackupTypes';
import WalletBackupStepTypes from '@/helpers/walletBackupStepTypes';

export default function useImportingWallet({ showImportModal = true } = {}) {
const { accountAddress } = useAccountSettings();
Expand Down Expand Up @@ -75,7 +77,7 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
const handleSetSeedPhrase = useCallback(
(text: string) => {
if (isImporting) return null;
return setSeedPhrase(text);
return setSeedPhrase(text.trim());
},
[isImporting]
);
Expand Down Expand Up @@ -282,6 +284,9 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
if (!wasImporting && isImporting) {
const asyncFn = async () => {
const input = resolvedAddress ? resolvedAddress : sanitizeSeedPhrase(seedPhrase);
walletLoadingStore.setState({
loadingState: WalletLoadingStates.IMPORTING_WALLET,
});

if (!showImportModal) {
await walletInit(
Expand Down Expand Up @@ -313,21 +318,16 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
.then(success => {
ios && handleSetImporting(false);
if (success) {
dangerouslyGetParent?.()?.goBack();
InteractionManager.runAfterInteractions(async () => {
if (previousWalletCount === 0) {
navigate(Routes.SWIPE_LAYOUT, {
params: { initialized: true },
Navigation.handleAction(
Routes.SWIPE_LAYOUT,
{
screen: Routes.WALLET_SCREEN,
});
} else {
dangerouslyGetParent?.()?.goBack();

navigate(Routes.SWIPE_LAYOUT, {
params: { initialized: true },
screen: Routes.WALLET_SCREEN,
});
}
},
previousWalletCount === 0
);

if (android) {
handleSetImporting(false);
}
Expand Down Expand Up @@ -356,6 +356,11 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
analytics.track('Imported seed phrase', {
isWalletEthZero,
});

walletLoadingStore.setState({
loadingState: null,
});
dangerouslyGetParent?.()?.goBack();
});
} else {
if (android) {
Expand Down
2 changes: 0 additions & 2 deletions src/react-native-cool-modals/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export function Portal() {
return null;
}

console.log('blockTouches', blockTouches);

return (
<Wrapper
pointerEvents={blockTouches ? 'none' : 'auto'}
Expand Down

0 comments on commit 6c94cd4

Please sign in to comment.