Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BrtqKr committed Jul 11, 2024
1 parent 26cfd19 commit 7276b07
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {NavigationState} from '@react-navigation/native';
import {DefaultTheme, findFocusedRoute, NavigationContainer} from '@react-navigation/native';
import React, {useContext, useEffect, useMemo, useRef} from 'react';
import {useOnyx} from 'react-native-onyx';
import HybridAppMiddleware from '@components/HybridAppMiddleware';
import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
Expand All @@ -12,6 +13,7 @@ import Log from '@libs/Log';
import {getPathFromURL} from '@libs/Url';
import {updateLastVisitedPath} from '@userActions/App';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import AppNavigator from './AppNavigator';
import getPolicyIDFromState from './getPolicyIDFromState';
Expand Down Expand Up @@ -77,20 +79,28 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
const {isSmallScreenWidth} = useWindowDimensions();
const {setActiveWorkspaceID} = useActiveWorkspace();

<<<<<<< HEAD
const [hasCompletedGuidedSetupFlow] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasCompletedGuidedSetupFlowSelector,
});
const [user] = useOnyx(ONYXKEYS.USER);

const initialState = useMemo(() => {
if (!user || user.isFromPublicDomain) {
return;
}
// If the user haven't completed the flow, we want to always redirect them to the onboarding flow.
if (!hasCompletedGuidedSetupFlow) {
const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT, linkingConfig.config);
const initialState = useMemo(
() => {
if (!user || user.isFromPublicDomain) {
return;
}

if (!lastVisitedPath) {
return undefined;
}

const path = initialUrl ? getPathFromURL(initialUrl) : null;

// For non-nullable paths we don't want to set initial state
if (path) {
return;
}

const {adaptedState} = getAdaptedStateFromPath(lastVisitedPath, linkingConfig.config);
return adaptedState;
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[],
);
Expand Down

0 comments on commit 7276b07

Please sign in to comment.