Skip to content

Commit

Permalink
Rename actionName and actionParams variables in linkTo
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Jun 26, 2024
1 parent 8898f18 commit 89b6676
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libs/Navigation/linkTo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
const topRouteName = lastRoute?.name;

// CentralPane screens aren't nested in any navigator, if actionPayloadParams?.screen is undefined, it means the screen name and parameters have to be read directly from action.payload
const actionName = actionPayloadParams?.screen ?? action.payload.name;
const actionParams = actionPayloadParams?.params ?? actionPayloadParams;
const targetName = actionPayloadParams?.screen ?? action.payload.name;
const targetParams = actionPayloadParams?.params ?? actionPayloadParams;
const isTargetNavigatorOnTop = topRouteName === action.payload.name;

const isTargetScreenDifferentThanCurrent = !!(!topmostCentralPaneRoute || topmostCentralPaneRoute.name !== actionName);
const isTargetScreenDifferentThanCurrent = !!(!topmostCentralPaneRoute || topmostCentralPaneRoute.name !== targetName);
const areParamsDifferent =
actionName === SCREENS.REPORT
targetName === SCREENS.REPORT
? getTopmostReportId(rootState) !== getTopmostReportId(stateFromPath)
: !shallowCompare(
omitBy(topmostCentralPaneRoute?.params as Record<string, unknown> | undefined, (value) => value === undefined),
omitBy(actionParams as Record<string, unknown> | undefined, (value) => value === undefined),
omitBy(targetParams as Record<string, unknown> | undefined, (value) => value === undefined),
);

// If this action is navigating to the report screen and the top most navigator is different from the one we want to navigate - PUSH the new screen to the top of the stack by default
Expand Down Expand Up @@ -114,8 +114,8 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
}

// If we navigate to SCREENS.SEARCH.CENTRAL_PANE, it's necessary to pass the current policyID, but we have to remember that this param is called policyIDs on this page
if (actionName === SCREENS.SEARCH.CENTRAL_PANE && actionParams && policyID) {
(actionParams as Record<string, string | undefined>).policyIDs = policyID;
if (targetName === SCREENS.SEARCH.CENTRAL_PANE && targetParams && policyID) {
(targetParams as Record<string, string | undefined>).policyIDs = policyID;
}

// If the type is UP, we deeplinked into one of the RHP flows and we want to replace the current screen with the previous one in the flow
Expand Down

0 comments on commit 89b6676

Please sign in to comment.