@@ -4,64 +4,29 @@ import {tryNewDotOnyxSelector} from '@selectors/Onboarding';
44import Onyx from 'react-native-onyx' ;
55import type { OnyxEntry } from 'react-native-onyx' ;
66import Log from '@libs/Log' ;
7- import Navigation from '@libs/Navigation/Navigation' ;
87import isProductTrainingElementDismissed from '@libs/TooltipUtils' ;
98import CONST from '@src/CONST' ;
109import NAVIGATORS from '@src/NAVIGATORS' ;
1110import ONYXKEYS from '@src/ONYXKEYS' ;
1211import ROUTES from '@src/ROUTES' ;
1312import SCREENS from '@src/SCREENS' ;
14- import type { DismissedProductTraining , Session } from '@src/types/onyx' ;
13+ import type { DismissedProductTraining } from '@src/types/onyx' ;
1514import type { GuardResult , NavigationGuard } from './types' ;
1615
1716let hasBeenAddedToNudgeMigration = false ;
1817let dismissedProductTraining : OnyxEntry < DismissedProductTraining > ;
19- let session : OnyxEntry < Session > ;
20- let isLoadingApp = true ;
2118
2219let hasRedirectedToMigratedUserModal = false ;
2320
2421function resetSessionFlag ( ) {
2522 hasRedirectedToMigratedUserModal = false ;
2623}
2724
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- /**
49- * Called by guards/index.ts when session or loading app state changes.
50- * Reuses the shared Onyx subscriptions from guards/index.ts to avoid duplicate connections
51- * that cause extra renders in performance tests.
52- */
53- function onSessionOrLoadingAppChanged ( sessionValue : OnyxEntry < Session > , isLoadingAppValue : boolean ) {
54- session = sessionValue ;
55- isLoadingApp = isLoadingAppValue ;
56- navigateToMigratedUserWelcomeModalIfReady ( ) ;
57- }
58-
5925Onyx . connectWithoutView ( {
6026 key : ONYXKEYS . NVP_TRY_NEW_DOT ,
6127 callback : ( value ) => {
6228 const result = value ? tryNewDotOnyxSelector ( value ) : undefined ;
6329 hasBeenAddedToNudgeMigration = result ?. hasBeenAddedToNudgeMigration ?? false ;
64- navigateToMigratedUserWelcomeModalIfReady ( ) ;
6530 } ,
6631} ) ;
6732
@@ -133,4 +98,4 @@ const MigratedUserWelcomeModalGuard: NavigationGuard = {
13398} ;
13499
135100export default MigratedUserWelcomeModalGuard ;
136- export { resetSessionFlag , onSessionOrLoadingAppChanged } ;
101+ export { resetSessionFlag } ;
0 commit comments