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

Fix Android import first wallet navigation stack #6393

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
34 changes: 19 additions & 15 deletions src/hooks/useImportingWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import { WrappedAlert as Alert } from '@/helpers/alert';
import { analytics, analyticsV2 } from '@/analytics';
import { PROFILES, useExperimentalFlag } from '@/config';
import { fetchReverseRecord } from '@/handlers/ens';
import { getProvider, isValidBluetoothDeviceId, resolveUnstoppableDomain } from '@/handlers/web3';
import { getProvider, 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,6 +29,8 @@ 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';

Expand Down Expand Up @@ -75,7 +76,7 @@ export default function useImportingWallet({ showImportModal = true } = {}) {
const handleSetSeedPhrase = useCallback(
(text: string) => {
if (isImporting) return null;
return setSeedPhrase(text);
return setSeedPhrase(text.trim());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this removes any extraneous newlines when pasting. Got tired of seeing that.

},
[isImporting]
);
Expand Down Expand Up @@ -282,6 +283,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 +317,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 +355,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
Loading