Skip to content

Commit

Permalink
Merge pull request #53629 from FitseTLT/fix-navigate-back-with-backTo…
Browse files Browse the repository at this point in the history
…-for-verify-page
  • Loading branch information
dangrous authored Dec 10, 2024
2 parents fd009af + c0f47de commit 7a98f0d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pages/settings/Wallet/VerifyAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) {
const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true);

const navigateForwardTo = route.params?.forwardTo;
const backTo = route.params?.backTo;

useBeforeRemove(() => setIsValidateCodeActionModalVisible(false));

Expand All @@ -50,8 +51,8 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) {
const closeModal = useCallback(() => {
// Disable modal visibility so the navigation is animated
setIsValidateCodeActionModalVisible(false);
Navigation.goBack();
}, []);
Navigation.goBack(backTo);
}, [backTo]);

// Handle navigation once the user is validated
useEffect(() => {
Expand All @@ -64,9 +65,9 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) {
if (navigateForwardTo) {
Navigation.navigate(navigateForwardTo, CONST.NAVIGATION.TYPE.UP);
} else {
Navigation.goBack();
Navigation.goBack(backTo);
}
}, [isUserValidated, navigateForwardTo]);
}, [isUserValidated, navigateForwardTo, backTo]);

// Once user is validated or the modal is dismissed, we don't want to show empty content.
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -78,7 +79,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) {
>
<HeaderWithBackButton
title={translate('contacts.validateAccount')}
onBackButtonPress={() => Navigation.goBack()}
onBackButtonPress={() => Navigation.goBack(backTo)}
/>
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
</ScreenWrapper>
Expand Down

0 comments on commit 7a98f0d

Please sign in to comment.