Skip to content

Commit

Permalink
Cleanup linkTo and getMinimalAction
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Oct 8, 2024
1 parent e2ad744 commit 53fe13e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import getMinimalAction from './linkTo/getMinimalAction';
import navigationRef from './navigationRef';
import setNavigationActionToMicrotaskQueue from './setNavigationActionToMicrotaskQueue';
import type {NavigationPartialRoute, NavigationStateRoute, RootStackParamList, SplitNavigatorLHNScreen, SplitNavigatorParamListType, State, StateOrRoute} from './types';

Check failure on line 33 in src/libs/Navigation/Navigation.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Delete `';⏎import·createSplitNavigator·from·'./linkingConfig/createSplitNavigator`
import createSplitNavigator from './linkingConfig/createSplitNavigator';

const SPLIT_NAVIGATOR_TO_SIDEBAR_MAP: Record<keyof SplitNavigatorParamListType, SplitNavigatorLHNScreen> = {
[NAVIGATORS.REPORTS_SPLIT_NAVIGATOR]: SCREENS.HOME,
Expand Down
9 changes: 7 additions & 2 deletions src/libs/Navigation/linkTo/getMinimalAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import type {Writable} from 'type-fest';
import type {State} from '@navigation/types';
import type {ActionPayload} from './types';

type MinimalAction = {
action: Writable<NavigationAction>;
targetState: State | undefined;
};

/**
* Motivation for this function is described in NAVIGATION.md
*
* @param action action generated by getActionFromState
* @param state The root state
* @returns minimalAction minimal action is the action that we should dispatch
*/
function getMinimalAction(action: NavigationAction, state: NavigationState): Writable<NavigationAction> {
function getMinimalAction(action: NavigationAction, state: NavigationState): MinimalAction {
let currentAction: NavigationAction = action;
let currentState: State | undefined = state;
let currentTargetKey: string | undefined;
Expand All @@ -36,7 +41,7 @@ function getMinimalAction(action: NavigationAction, state: NavigationState): Wri
target: currentTargetKey,
};
}
return currentAction;
return {action: currentAction, targetState: currentState};
}

export default getMinimalAction;
2 changes: 1 addition & 1 deletion src/libs/Navigation/linkTo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH;
}

const minimalAction = getMinimalAction(action, navigation.getRootState());
const {action: minimalAction} = getMinimalAction(action, navigation.getRootState());
navigation.dispatch(minimalAction);
}
47 changes: 0 additions & 47 deletions src/libs/Navigation/newLinkTo/getMinimalAction.ts

This file was deleted.

0 comments on commit 53fe13e

Please sign in to comment.