Skip to content

Commit b76596f

Browse files
MelvinBoteh2077
andcommitted
Add active trigger for migrated user welcome modal and navigate to Home on dismiss
The migrated user welcome modal guard was purely passive — it only evaluated during navigation actions. When nvp_tryNewDot was updated via Onyx, the guard condition became true silently but no navigation was dispatched, so the modal only appeared on the next user-initiated navigation. Added proactive navigation in the Onyx callbacks: when session is authenticated, app is loaded, and nudge migration is active, navigate directly to the modal route. Also added Navigation.navigate(ROUTES.HOME) in MigratedUserWelcomeModal's onClose handler so dismissing the modal navigates the user to the Reports page as expected. Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
1 parent 61197b5 commit b76596f

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/components/MigratedUserWelcomeModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import {openExternalLink} from '@libs/actions/Link';
1111
import {dismissProductTraining} from '@libs/actions/Welcome';
1212
import convertToLTR from '@libs/convertToLTR';
1313
import Log from '@libs/Log';
14+
import Navigation from '@libs/Navigation/Navigation';
1415
import variables from '@styles/variables';
1516
import CONST from '@src/CONST';
17+
import ROUTES from '@src/ROUTES';
1618
import type {FeatureListItem} from './FeatureList';
1719
import FeatureTrainingModal from './FeatureTrainingModal';
1820
import Icon from './Icon';
@@ -58,6 +60,7 @@ function MigratedUserWelcomeModal() {
5860
const onClose = () => {
5961
Log.hmmm('[MigratedUserWelcomeModal] onClose called, dismissing product training');
6062
dismissProductTraining(CONST.MIGRATED_USER_WELCOME_MODAL);
63+
Navigation.navigate(ROUTES.HOME);
6164
};
6265

6366
const featureListContent = (

src/libs/Navigation/guards/MigratedUserWelcomeModalGuard.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,69 @@ import {tryNewDotOnyxSelector} from '@selectors/Onboarding';
44
import Onyx from 'react-native-onyx';
55
import type {OnyxEntry} from 'react-native-onyx';
66
import Log from '@libs/Log';
7+
import Navigation from '@libs/Navigation/Navigation';
78
import isProductTrainingElementDismissed from '@libs/TooltipUtils';
89
import CONST from '@src/CONST';
910
import NAVIGATORS from '@src/NAVIGATORS';
1011
import ONYXKEYS from '@src/ONYXKEYS';
1112
import ROUTES from '@src/ROUTES';
1213
import SCREENS from '@src/SCREENS';
13-
import type {DismissedProductTraining} from '@src/types/onyx';
14+
import type {DismissedProductTraining, Session} from '@src/types/onyx';
1415
import type {GuardResult, NavigationGuard} from './types';
1516

1617
let hasBeenAddedToNudgeMigration = false;
1718
let dismissedProductTraining: OnyxEntry<DismissedProductTraining>;
19+
let session: OnyxEntry<Session>;
20+
let isLoadingApp = true;
1821

1922
let hasRedirectedToMigratedUserModal = false;
2023

2124
function resetSessionFlag() {
2225
hasRedirectedToMigratedUserModal = false;
2326
}
2427

28+
/**
29+
* Proactively navigate to the migrated user welcome modal when all conditions are met,
30+
* without waiting for a user-initiated navigation action.
31+
*/
32+
function navigateToMigratedUserWelcomeModalIfReady() {
33+
if (
34+
!session?.authToken ||
35+
isLoadingApp ||
36+
hasRedirectedToMigratedUserModal ||
37+
!hasBeenAddedToNudgeMigration ||
38+
isProductTrainingElementDismissed('migratedUserWelcomeModal', dismissedProductTraining)
39+
) {
40+
return;
41+
}
42+
43+
Log.info('[MigratedUserWelcomeModalGuard] Proactively navigating to migrated user welcome modal');
44+
hasRedirectedToMigratedUserModal = true;
45+
Navigation.navigate(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute());
46+
}
47+
48+
Onyx.connectWithoutView({
49+
key: ONYXKEYS.SESSION,
50+
callback: (value) => {
51+
session = value;
52+
navigateToMigratedUserWelcomeModalIfReady();
53+
},
54+
});
55+
56+
Onyx.connectWithoutView({
57+
key: ONYXKEYS.IS_LOADING_APP,
58+
callback: (value) => {
59+
isLoadingApp = value ?? true;
60+
navigateToMigratedUserWelcomeModalIfReady();
61+
},
62+
});
63+
2564
Onyx.connectWithoutView({
2665
key: ONYXKEYS.NVP_TRY_NEW_DOT,
2766
callback: (value) => {
2867
const result = value ? tryNewDotOnyxSelector(value) : undefined;
2968
hasBeenAddedToNudgeMigration = result?.hasBeenAddedToNudgeMigration ?? false;
69+
navigateToMigratedUserWelcomeModalIfReady();
3070
},
3171
});
3272

0 commit comments

Comments
 (0)