Skip to content

Commit

Permalink
chore(suite-native): cancel pin only if it was requested
Browse files Browse the repository at this point in the history
- Add missing parenthesis
  • Loading branch information
matejkriz committed Jul 31, 2024
1 parent 3e3b9ef commit 207216c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { selectIsDeviceDiscoveryActive } from '@suite-common/wallet-core';
import {
cancelPassphraseAndSelectStandardDeviceThunk,
selectIsCreatingNewPassphraseWallet,
selectDeviceRequestedPin,
} from '@suite-native/device-authorization';

import { ConnectingTrezorHelp } from './ConnectingTrezorHelp';
Expand All @@ -41,6 +42,7 @@ export const ConnectDeviceScreenHeader = ({

const isDiscoveryActive = useSelector(selectIsDeviceDiscoveryActive);
const isCreatingNewWalletInstance = useSelector(selectIsCreatingNewPassphraseWallet);
const hasDeviceRequestedPin = useSelector(selectDeviceRequestedPin);

const handleCancel = useCallback(() => {
if (isDiscoveryActive) {
Expand All @@ -59,10 +61,13 @@ export const ConnectDeviceScreenHeader = ({
});
} else {
// Remove unauthorized passphrase device if it was created before prompting the PIN.
if (isCreatingNewWalletInstance)
if (isCreatingNewWalletInstance) {
dispatch(cancelPassphraseAndSelectStandardDeviceThunk());
}

TrezorConnect.cancel('pin-cancelled');
if (hasDeviceRequestedPin) {
TrezorConnect.cancel('pin-cancelled');
}
if (navigation.canGoBack()) {
navigation.goBack();
}
Expand All @@ -74,6 +79,7 @@ export const ConnectDeviceScreenHeader = ({
navigation,
showAlert,
isCreatingNewWalletInstance,
hasDeviceRequestedPin,
]);

// Handle hardware back button press same as cancel button
Expand Down

0 comments on commit 207216c

Please sign in to comment.