Skip to content

Commit

Permalink
Rename createSplitNavigator to getInitialSplitNavigatorState
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Nov 26, 2024
1 parent 0cc4340 commit 5f0631a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ExtractRouteType<T extends SplitNavigatorSidebarScreen> = Extract<keyof Spl
// The function getPathFromState that we are using in some places isn't working correctly without defined index.
const getRoutesWithIndex = (routes: NavigationPartialRoute[]): PartialState<NavigationState> => ({routes, index: routes.length - 1});

function createSplitNavigator<T extends SplitNavigatorSidebarScreen>(
function getInitialSplitNavigatorState<T extends SplitNavigatorSidebarScreen>(
splitNavigatorLHN: NavigationPartialRoute<T>,
route?: NavigationPartialRoute<ExtractRouteType<T>>,
splitNavigatorParams?: Record<string, string>,
Expand All @@ -26,4 +26,4 @@ function createSplitNavigator<T extends SplitNavigatorSidebarScreen>(
};
}

export default createSplitNavigator;
export default getInitialSplitNavigatorState;
4 changes: 2 additions & 2 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import ROUTES, {HYBRID_APP_ROUTES} from '@src/ROUTES';
import SCREENS, {PROTECTED_SCREENS} from '@src/SCREENS';
import type {Report} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import getInitialSplitNavigatorState from './AppNavigator/createSplitStackNavigator/getInitialSplitNavigatorState';
import {
createSplitNavigator,
getMinimalAction,
getPolicyIDFromState,
getStateFromPath,
Expand Down Expand Up @@ -314,7 +314,7 @@ function resetToHome() {
name: SCREENS.REPORT,
}
: undefined;
const payload = createSplitNavigator({name: SCREENS.HOME}, splitNavigatorMainScreen);
const payload = getInitialSplitNavigatorState({name: SCREENS.HOME}, splitNavigatorMainScreen);
navigationRef.dispatch({payload, type: 'REPLACE', target: rootState.key});
}

Expand Down
10 changes: 5 additions & 5 deletions src/libs/Navigation/helpers/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {NavigationState, PartialState, Route} from '@react-navigation/nativ
import {findFocusedRoute, getStateFromPath} from '@react-navigation/native';
import pick from 'lodash/pick';
import {isAnonymousUser} from '@libs/actions/Session';
import getInitialSplitNavigatorState from '@libs/Navigation/AppNavigator/createSplitStackNavigator/getInitialSplitNavigatorState';
import config from '@libs/Navigation/linkingConfig/config';
import RELATIONS from '@libs/Navigation/linkingConfig/RELATIONS';
import type {NavigationPartialRoute, RootStackParamList} from '@libs/Navigation/types';
Expand All @@ -10,7 +11,6 @@ import * as ReportConnection from '@libs/ReportConnection';
import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import createSplitNavigator from './createSplitNavigator';
import extractPolicyIDFromQuery from './extractPolicyIDFromQuery';
import getParamsFromRoute from './getParamsFromRoute';
import {isFullScreenName} from './isNavigatorName';
Expand Down Expand Up @@ -70,7 +70,7 @@ function getMatchingFullScreenRoute(route: NavigationPartialRoute, policyID?: st
}

if (RELATIONS.RHP_TO_SIDEBAR[route.name]) {
return createSplitNavigator(
return getInitialSplitNavigatorState(
{
name: RELATIONS.RHP_TO_SIDEBAR[route.name],
},
Expand All @@ -82,7 +82,7 @@ function getMatchingFullScreenRoute(route: NavigationPartialRoute, policyID?: st
if (RELATIONS.RHP_TO_WORKSPACE[route.name]) {
const paramsFromRoute = getParamsFromRoute(RELATIONS.RHP_TO_WORKSPACE[route.name]);

return createSplitNavigator(
return getInitialSplitNavigatorState(
{
name: SCREENS.WORKSPACE.INITIAL,
params: paramsFromRoute.length > 0 ? pick(route.params, paramsFromRoute) : undefined,
Expand All @@ -97,7 +97,7 @@ function getMatchingFullScreenRoute(route: NavigationPartialRoute, policyID?: st
if (RELATIONS.RHP_TO_SETTINGS[route.name]) {
const paramsFromRoute = getParamsFromRoute(RELATIONS.RHP_TO_SETTINGS[route.name]);

return createSplitNavigator(
return getInitialSplitNavigatorState(
{
name: SCREENS.SETTINGS.ROOT,
},
Expand Down Expand Up @@ -128,7 +128,7 @@ function getDefaultFullScreenRoute(route?: NavigationPartialRoute, policyID?: st
return fallbackRoute;
}

return createSplitNavigator(
return getInitialSplitNavigatorState(
{
name: SCREENS.HOME,
},
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from './isNavigatorName';
export * from './linkTo/types';
export {default as closeRHPFlow} from './closeRHPFlow';
export {default as createNormalizedConfigs} from './createNormalizedConfigs';
export {default as createSplitNavigator} from './createSplitNavigator';
export {default as customGetPathFromState} from './customGetPathFromState';
export {default as extractPolicyIDFromQuery} from './extractPolicyIDFromQuery';
export {default as getAdaptedStateFromPath} from './getAdaptedStateFromPath';
Expand Down

0 comments on commit 5f0631a

Please sign in to comment.