From 7a13a236d95da623c58cfbcb5aa84ff01d8d3b8e Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Sat, 24 Aug 2024 16:14:53 +0700 Subject: [PATCH 1/4] Make onboarding continue from last visited onboarding page --- src/ONYXKEYS.ts | 4 +++ src/components/ExplanationModal.tsx | 3 +- .../BottomTabBar.tsx | 4 +-- src/libs/Navigation/NavigationRoot.tsx | 9 +++-- src/libs/actions/Report.ts | 9 ++++- src/libs/actions/Welcome.ts | 34 ++++++++++++++++++- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b7b6cf53a176..49eb58f9ea63 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -336,6 +336,9 @@ const ONYXKEYS = { /** Onboarding Purpose selected by the user during Onboarding flow */ ONBOARDING_ADMINS_CHAT_REPORT_ID: 'onboardingAdminsChatReportID', + // Stores onboarding last visited path + ONBOARDING_LAST_VISITED_PATH: 'onboardingLastVisitedPath', + // Max width supported for HTML element MAX_CANVAS_WIDTH: 'maxCanvasWidth', @@ -862,6 +865,7 @@ type OnyxValuesMapping = { [ONYXKEYS.ONBOARDING_ERROR_MESSAGE]: string; [ONYXKEYS.ONBOARDING_POLICY_ID]: string; [ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID]: string; + [ONYXKEYS.ONBOARDING_LAST_VISITED_PATH]: string; [ONYXKEYS.IS_SEARCHING_FOR_REPORTS]: boolean; [ONYXKEYS.LAST_VISITED_PATH]: string | undefined; [ONYXKEYS.VERIFY_3DS_SUBSCRIPTION]: string; diff --git a/src/components/ExplanationModal.tsx b/src/components/ExplanationModal.tsx index c6294f600993..e88dc1dab0e5 100644 --- a/src/components/ExplanationModal.tsx +++ b/src/components/ExplanationModal.tsx @@ -4,7 +4,6 @@ import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; import FeatureTrainingModal from './FeatureTrainingModal'; function ExplanationModal() { @@ -18,7 +17,7 @@ function ExplanationModal() { onNotCompleted: () => { setTimeout(() => { Navigation.isNavigationReady().then(() => { - Navigation.navigate(ROUTES.ONBOARDING_ROOT.route); + Navigation.navigate(Welcome.getOnboardingInitialPath()); }); }, variables.welcomeVideoDelay); }, diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index f023e94bec9b..a672d211c98e 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -12,7 +12,6 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Session from '@libs/actions/Session'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; -import linkingConfig from '@libs/Navigation/linkingConfig'; import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import type {RootStackParamList, State} from '@libs/Navigation/types'; @@ -21,6 +20,7 @@ import * as PolicyUtils from '@libs/PolicyUtils'; import {getCurrentSearchParams} from '@libs/SearchUtils'; import type {BrickRoad} from '@libs/WorkspacesSettingsUtils'; import {getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils'; +import linkingConfig from '@navigation/linkingConfig'; import BottomTabAvatar from '@pages/home/sidebar/BottomTabAvatar'; import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton'; import variables from '@styles/variables'; @@ -67,7 +67,7 @@ function BottomTabBar({selectedTab}: BottomTabBarProps) { Welcome.isOnboardingFlowCompleted({ onNotCompleted: () => { - const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT.route, linkingConfig.config); + const {adaptedState} = getAdaptedStateFromPath(Welcome.getOnboardingInitialPath(), linkingConfig.config); navigationRef.resetRoot(adaptedState); }, }); diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index 152594ba6b3e..df65e55e96a0 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -14,10 +14,12 @@ import hasCompletedGuidedSetupFlowSelector from '@libs/hasCompletedGuidedSetupFl import Log from '@libs/Log'; import {getPathFromURL} from '@libs/Url'; import {updateLastVisitedPath} from '@userActions/App'; +import {updateOnboardingLastVisitedPath} from '@userActions/Welcome'; +import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; +import type {Route} from '@src/ROUTES'; import AppNavigator from './AppNavigator'; import getPolicyIDFromState from './getPolicyIDFromState'; import linkingConfig from './linkingConfig'; @@ -58,6 +60,9 @@ function parseAndLogRoute(state: NavigationState) { if (focusedRoute && !CONST.EXCLUDE_FROM_LAST_VISITED_PATH.includes(focusedRoute?.name)) { updateLastVisitedPath(currentPath); + if (currentPath.startsWith(`/${ROUTES.ONBOARDING_ROOT.route}`)) { + updateOnboardingLastVisitedPath(currentPath); + } } // Don't log the route transitions from OldDot because they contain authTokens @@ -98,7 +103,7 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady, sh // If the user haven't completed the flow, we want to always redirect them to the onboarding flow. // We also make sure that the user is authenticated. if (!hasCompletedGuidedSetupFlow && authenticated && !shouldShowRequire2FAModal) { - const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT.route, linkingConfig.config); + const {adaptedState} = getAdaptedStateFromPath(Welcome.getOnboardingInitialPath(), linkingConfig.config); return adaptedState; } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7eb7e01d6edd..9c57c178ec1c 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -64,6 +64,7 @@ import isPublicScreenRoute from '@libs/isPublicScreenRoute'; import * as Localize from '@libs/Localize'; import Log from '@libs/Log'; import {registerPaginationConfig} from '@libs/Middleware/Pagination'; +import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import {isOnboardingFlowName} from '@libs/NavigationUtils'; import type {NetworkStatus} from '@libs/NetworkConnection'; @@ -82,6 +83,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import {doesReportBelongToWorkspace} from '@libs/ReportUtils'; import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation'; import Visibility from '@libs/Visibility'; +import linkingConfig from '@navigation/linkingConfig'; import CONFIG from '@src/CONFIG'; import type {OnboardingPurposeType} from '@src/CONST'; import CONST from '@src/CONST'; @@ -2700,7 +2702,12 @@ function openReportFromDeepLink(url: string) { // We need skip deeplinking if the user hasn't completed the guided setup flow. if (!hasCompletedGuidedSetupFlow) { - Welcome.isOnboardingFlowCompleted({onNotCompleted: () => Navigation.navigate(ROUTES.ONBOARDING_ROOT.getRoute())}); + Welcome.isOnboardingFlowCompleted({ + onNotCompleted: () => { + const {adaptedState} = getAdaptedStateFromPath(Welcome.getOnboardingInitialPath(), linkingConfig.config); + navigationRef.resetRoot(adaptedState); + }, + }); return; } diff --git a/src/libs/actions/Welcome.ts b/src/libs/actions/Welcome.ts index d54314ae6f05..3c7a169ba888 100644 --- a/src/libs/actions/Welcome.ts +++ b/src/libs/actions/Welcome.ts @@ -4,10 +4,13 @@ import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; import Navigation from '@libs/Navigation/Navigation'; +import getStateFromPath from '@navigation/getStateFromPath'; import variables from '@styles/variables'; import type {OnboardingPurposeType} from '@src/CONST'; +import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {Route} from '@src/ROUTES'; import type Onboarding from '@src/types/onyx/Onboarding'; import type TryNewDot from '@src/types/onyx/TryNewDot'; @@ -15,6 +18,7 @@ type OnboardingData = Onboarding | [] | undefined; let isLoadingReportData = true; let tryNewDotData: TryNewDot | undefined; +let onboardingInitialPath = ''; let onboarding: OnboardingData; type HasCompletedOnboardingFlowProps = { @@ -97,7 +101,7 @@ function handleHybridAppOnboarding() { isOnboardingFlowCompleted({ onNotCompleted: () => setTimeout(() => { - Navigation.navigate(ROUTES.ONBOARDING_ROOT.route); + Navigation.navigate(getOnboardingInitialPath()); }, variables.explanationModalDelay), }), }); @@ -152,6 +156,19 @@ function setOnboardingPolicyID(policyID?: string) { Onyx.set(ONYXKEYS.ONBOARDING_POLICY_ID, policyID ?? null); } +function updateOnboardingLastVisitedPath(path: string) { + Onyx.merge(ONYXKEYS.ONBOARDING_LAST_VISITED_PATH, path); +} + +function getOnboardingInitialPath(): Route { + const state = getStateFromPath(onboardingInitialPath as Route); + if (state?.routes?.at(-1)?.name !== NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) { + return ROUTES.ONBOARDING_ROOT.getRoute() as Route; + } + + return onboardingInitialPath as Route; +} + function completeHybridAppOnboarding() { const optimisticData: OnyxUpdate[] = [ { @@ -188,6 +205,18 @@ Onyx.connect({ }, }); +const onboardingLastVisitedPathConnection = Onyx.connect({ + key: ONYXKEYS.ONBOARDING_LAST_VISITED_PATH, + callback: (value) => { + if (value === undefined) { + return; + } + + onboardingInitialPath = value.substring(1); + Onyx.disconnect(onboardingLastVisitedPathConnection); + }, +}); + Onyx.connect({ key: ONYXKEYS.IS_LOADING_REPORT_DATA, initWithStoredValues: false, @@ -213,12 +242,15 @@ function resetAllChecks() { resolveOnboardingFlowStatus = resolve; }); isLoadingReportData = true; + onboardingInitialPath = ''; } export { onServerDataReady, isOnboardingFlowCompleted, setOnboardingPurposeSelected, + getOnboardingInitialPath, + updateOnboardingLastVisitedPath, resetAllChecks, setOnboardingAdminsChatReportID, setOnboardingPolicyID, From 070e24bb530503b23d1fa65a2d6e26486ab39b00 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Sat, 24 Aug 2024 23:39:53 +0700 Subject: [PATCH 2/4] Fix navigation issues Signed-off-by: Tsaqif --- src/components/ExplanationModal.tsx | 3 ++- .../BottomTabBar.tsx | 9 ++----- src/libs/actions/Report.ts | 8 +------ src/libs/actions/Welcome.ts | 24 ++++++++++++++++--- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/components/ExplanationModal.tsx b/src/components/ExplanationModal.tsx index e88dc1dab0e5..1275de825204 100644 --- a/src/components/ExplanationModal.tsx +++ b/src/components/ExplanationModal.tsx @@ -17,7 +17,8 @@ function ExplanationModal() { onNotCompleted: () => { setTimeout(() => { Navigation.isNavigationReady().then(() => { - Navigation.navigate(Welcome.getOnboardingInitialPath()); + Welcome.startOnboardingFlow(); + // Navigation.navigate(Welcome.getOnboardingInitialPath()); }); }, variables.welcomeVideoDelay); }, diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index a672d211c98e..3a9f3c28c843 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -12,15 +12,13 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Session from '@libs/actions/Session'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; -import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; -import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; +import Navigation from '@libs/Navigation/Navigation'; import type {RootStackParamList, State} from '@libs/Navigation/types'; import {isCentralPaneName} from '@libs/NavigationUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import {getCurrentSearchParams} from '@libs/SearchUtils'; import type {BrickRoad} from '@libs/WorkspacesSettingsUtils'; import {getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils'; -import linkingConfig from '@navigation/linkingConfig'; import BottomTabAvatar from '@pages/home/sidebar/BottomTabAvatar'; import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton'; import variables from '@styles/variables'; @@ -66,10 +64,7 @@ function BottomTabBar({selectedTab}: BottomTabBarProps) { } Welcome.isOnboardingFlowCompleted({ - onNotCompleted: () => { - const {adaptedState} = getAdaptedStateFromPath(Welcome.getOnboardingInitialPath(), linkingConfig.config); - navigationRef.resetRoot(adaptedState); - }, + onNotCompleted: () => Welcome.startOnboardingFlow(), }); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 9c57c178ec1c..6307d69949fa 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -64,7 +64,6 @@ import isPublicScreenRoute from '@libs/isPublicScreenRoute'; import * as Localize from '@libs/Localize'; import Log from '@libs/Log'; import {registerPaginationConfig} from '@libs/Middleware/Pagination'; -import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import {isOnboardingFlowName} from '@libs/NavigationUtils'; import type {NetworkStatus} from '@libs/NetworkConnection'; @@ -83,7 +82,6 @@ import * as ReportUtils from '@libs/ReportUtils'; import {doesReportBelongToWorkspace} from '@libs/ReportUtils'; import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation'; import Visibility from '@libs/Visibility'; -import linkingConfig from '@navigation/linkingConfig'; import CONFIG from '@src/CONFIG'; import type {OnboardingPurposeType} from '@src/CONST'; import CONST from '@src/CONST'; @@ -2703,10 +2701,7 @@ function openReportFromDeepLink(url: string) { // We need skip deeplinking if the user hasn't completed the guided setup flow. if (!hasCompletedGuidedSetupFlow) { Welcome.isOnboardingFlowCompleted({ - onNotCompleted: () => { - const {adaptedState} = getAdaptedStateFromPath(Welcome.getOnboardingInitialPath(), linkingConfig.config); - navigationRef.resetRoot(adaptedState); - }, + onNotCompleted: () => Welcome.startOnboardingFlow(), }); return; } @@ -2727,7 +2722,6 @@ function openReportFromDeepLink(url: string) { }); }); } - function getCurrentUserAccountID(): number { return currentUserAccountID; } diff --git a/src/libs/actions/Welcome.ts b/src/libs/actions/Welcome.ts index 3c7a169ba888..9c02f64452bc 100644 --- a/src/libs/actions/Welcome.ts +++ b/src/libs/actions/Welcome.ts @@ -3,8 +3,10 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; -import Navigation from '@libs/Navigation/Navigation'; +import linkingConfig from '@libs/Navigation/linkingConfig'; +import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import getStateFromPath from '@navigation/getStateFromPath'; +import getAdaptedStateFromPath from '@navigation/linkingConfig/getAdaptedStateFromPath'; import variables from '@styles/variables'; import type {OnboardingPurposeType} from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -50,6 +52,7 @@ function onServerDataReady(): Promise { return isServerDataReadyPromise; } +let isOnboardingInProgress = false; function isOnboardingFlowCompleted({onCompleted, onNotCompleted}: HasCompletedOnboardingFlowProps) { isOnboardingFlowStatusKnownPromise.then(() => { if (Array.isArray(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) { @@ -57,8 +60,10 @@ function isOnboardingFlowCompleted({onCompleted, onNotCompleted}: HasCompletedOn } if (onboarding?.hasCompletedGuidedSetupFlow) { + isOnboardingInProgress = false; onCompleted?.(); - } else { + } else if (!isOnboardingInProgress) { + isOnboardingInProgress = true; onNotCompleted?.(); } }); @@ -101,7 +106,7 @@ function handleHybridAppOnboarding() { isOnboardingFlowCompleted({ onNotCompleted: () => setTimeout(() => { - Navigation.navigate(getOnboardingInitialPath()); + startOnboardingFlow(); }, variables.explanationModalDelay), }), }); @@ -197,6 +202,17 @@ function completeHybridAppOnboarding() { API.write(WRITE_COMMANDS.COMPLETE_HYBRID_APP_ONBOARDING, {}, {optimisticData, failureData}); } +function startOnboardingFlow() { + const currentState = navigationRef.getRootState(); + if (currentState?.routes?.at(-1)?.name === NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) { + Navigation.closeAndNavigate(getOnboardingInitialPath()); + } else { + const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT.route, linkingConfig.config); + navigationRef.resetRoot(adaptedState); + Navigation.navigate(getOnboardingInitialPath()); + } +} + Onyx.connect({ key: ONYXKEYS.NVP_ONBOARDING, callback: (value) => { @@ -243,6 +259,7 @@ function resetAllChecks() { }); isLoadingReportData = true; onboardingInitialPath = ''; + isOnboardingInProgress = false; } export { @@ -257,4 +274,5 @@ export { completeHybridAppOnboarding, handleHybridAppOnboarding, setOnboardingErrorMessage, + startOnboardingFlow, }; From 1a1e96db29c9f6cb568cdcd943387dce1336c28f Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Sat, 24 Aug 2024 23:41:48 +0700 Subject: [PATCH 3/4] Remove unnecessary line Signed-off-by: Tsaqif --- src/components/ExplanationModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ExplanationModal.tsx b/src/components/ExplanationModal.tsx index 1275de825204..bf6bd04d4277 100644 --- a/src/components/ExplanationModal.tsx +++ b/src/components/ExplanationModal.tsx @@ -18,7 +18,6 @@ function ExplanationModal() { setTimeout(() => { Navigation.isNavigationReady().then(() => { Welcome.startOnboardingFlow(); - // Navigation.navigate(Welcome.getOnboardingInitialPath()); }); }, variables.welcomeVideoDelay); }, From f7d800bc0cfd6c243f5853fb6b6c80585589082a Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Sun, 25 Aug 2024 09:35:02 +0700 Subject: [PATCH 4/4] Fix navigation issues across platforms Signed-off-by: Tsaqif --- .../linkingConfig/getAdaptedStateFromPath.ts | 8 +++++--- src/libs/actions/Report.ts | 1 + src/libs/actions/Welcome.ts | 12 +++--------- .../BaseOnboardingPersonalDetails.tsx | 4 +++- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 611831544bdc..16bb1c89b6e8 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -47,7 +47,7 @@ type GetAdaptedStateReturnType = { metainfo: Metainfo; }; -type GetAdaptedStateFromPath = (...args: Parameters) => GetAdaptedStateReturnType; +type GetAdaptedStateFromPath = (...args: [...Parameters, shouldReplacePathInNestedState?: boolean]) => GetAdaptedStateReturnType; // The function getPathFromState that we are using in some places isn't working correctly without defined index. const getRoutesWithIndex = (routes: NavigationPartialRoute[]): PartialState => ({routes, index: routes.length - 1}); @@ -365,7 +365,7 @@ function getAdaptedState(state: PartialState }; } -const getAdaptedStateFromPath: GetAdaptedStateFromPath = (path, options) => { +const getAdaptedStateFromPath: GetAdaptedStateFromPath = (path, options, shouldReplacePathInNestedState = true) => { const normalizedPath = !path.startsWith('/') ? `/${path}` : path; const pathWithoutPolicyID = getPathWithoutPolicyID(normalizedPath); const isAnonymous = isAnonymousUser(); @@ -374,7 +374,9 @@ const getAdaptedStateFromPath: GetAdaptedStateFromPath = (path, options) => { const policyID = isAnonymous ? undefined : extractPolicyIDFromPath(path); const state = getStateFromPath(pathWithoutPolicyID, options) as PartialState>; - replacePathInNestedState(state, path); + if (shouldReplacePathInNestedState) { + replacePathInNestedState(state, path); + } if (state === undefined) { throw new Error('Unable to parse path'); } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 6307d69949fa..9a8f41ef9c3a 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2722,6 +2722,7 @@ function openReportFromDeepLink(url: string) { }); }); } + function getCurrentUserAccountID(): number { return currentUserAccountID; } diff --git a/src/libs/actions/Welcome.ts b/src/libs/actions/Welcome.ts index 9c02f64452bc..5bc515184464 100644 --- a/src/libs/actions/Welcome.ts +++ b/src/libs/actions/Welcome.ts @@ -168,7 +168,7 @@ function updateOnboardingLastVisitedPath(path: string) { function getOnboardingInitialPath(): Route { const state = getStateFromPath(onboardingInitialPath as Route); if (state?.routes?.at(-1)?.name !== NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) { - return ROUTES.ONBOARDING_ROOT.getRoute() as Route; + return ROUTES.ONBOARDING_ROOT.route as Route; } return onboardingInitialPath as Route; @@ -203,14 +203,8 @@ function completeHybridAppOnboarding() { } function startOnboardingFlow() { - const currentState = navigationRef.getRootState(); - if (currentState?.routes?.at(-1)?.name === NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) { - Navigation.closeAndNavigate(getOnboardingInitialPath()); - } else { - const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT.route, linkingConfig.config); - navigationRef.resetRoot(adaptedState); - Navigation.navigate(getOnboardingInitialPath()); - } + const {adaptedState} = getAdaptedStateFromPath(getOnboardingInitialPath(), linkingConfig.config, false); + navigationRef.resetRoot(adaptedState); } Onyx.connect({ diff --git a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx index 4e3ebd6d0578..04dce7f826ab 100644 --- a/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx +++ b/src/pages/OnboardingPersonalDetails/BaseOnboardingPersonalDetails.tsx @@ -75,7 +75,9 @@ function BaseOnboardingPersonalDetails({ Welcome.setOnboardingAdminsChatReportID(); Welcome.setOnboardingPolicyID(); - Navigation.dismissModal(); + // Navigate to HOME instead of dismissModal, because there is bug in small screen + // where the onboarding puropose page will be disaplayed briefly + Navigation.navigate(ROUTES.HOME); // Only navigate to concierge chat when central pane is visible // Otherwise stay on the chats screen.