Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 0 additions & 17 deletions src/components/MultifactorAuthentication/mfaNavigation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {createNavigationContainerRef, StackActions} from '@react-navigation/native';
import type {MultifactorAuthenticationModalNavigatorParamList} from '@libs/Navigation/types';
import CONFIG from '@src/CONFIG';
import SCREENS from '@src/SCREENS';

/**
Expand All @@ -16,12 +15,6 @@ type MultifactorAuthenticationModalNavigatorInternalParamList = MultifactorAuthe

const mfaNavigationRef = createNavigationContainerRef<MultifactorAuthenticationModalNavigatorInternalParamList>();

// Outcome screens are terminal states the flow ends on.
const OUTCOME_SCREENS = new Set<keyof MultifactorAuthenticationModalNavigatorParamList>([
SCREENS.MULTIFACTOR_AUTHENTICATION.OUTCOME_SUCCESS,
SCREENS.MULTIFACTOR_AUTHENTICATION.OUTCOME_FAILURE,
]);

// Screens that live inside this independent overlay navigator. REVOKE and AUTHORIZE_TRANSACTION are intentionally excluded: they
// render in the main RHP modal stack, not this tree.
const MFA_OVERLAY_SCREENS = new Set<string>([
Expand Down Expand Up @@ -71,16 +64,6 @@ function navigate<T extends keyof MultifactorAuthenticationModalNavigatorParamLi
return;
}

// In HybridApp the MFA overlay renders in an independent BaseNavigationContainer presented inside a native
// modal, where StackActions.replace silently fails to commit (the computed state is never applied), stranding
// the user on the spinner-bearing Prompt screen. For the terminal outcome screens we push instead, which
// commits reliably; outcome screens end the flow (the stack is reset when the overlay closes) so the extra
// stack entry has no downside. Standalone keeps replace, where it works as expected.
if (CONFIG.IS_HYBRID_APP && OUTCOME_SCREENS.has(screen)) {
mfaNavigationRef.dispatch(StackActions.push(screen, params));
return;
}

mfaNavigationRef.dispatch(StackActions.replace(screen, params));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseNavigationContainer, NavigationIndependentTree} from '@react-navigation/core';
import {BaseNavigationContainer, NavigationIndependentTree, StackActions} from '@react-navigation/core';
import type {StackCardInterpolationProps} from '@react-navigation/stack';
import React, {useEffect, useState} from 'react';
import {StyleSheet, View} from 'react-native';
Expand Down Expand Up @@ -117,7 +117,7 @@ function MultifactorAuthenticationModalNavigator() {
return;
}
if (mfaNavigationRef.isReady() && mfaNavigationRef.canGoBack()) {
mfaNavigationRef.goBack();
mfaNavigationRef.dispatch(StackActions.popToTop());
}
backdropProgress.set(withTiming(0, {duration: CONST.ANIMATED_TRANSITION}));
const handle = Navigation.runAfterUpcomingTransition(() => {
Expand Down
Loading