Skip to content

Commit

Permalink
Handle deeplinking to report with policyID in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Sep 23, 2024
1 parent a254890 commit eba231e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
// };

// We need to check what is defined to know what we need to add.
const WorkspaceNavigator = state.routes.find((route) => route.name === NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR);
const workspaceNavigator = state.routes.find((route) => route.name === NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR);
const reportNavigator = state.routes.find((route) => route.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR);
const rhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR);
const lhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.LEFT_MODAL_NAVIGATOR);
const onboardingModalNavigator = state.routes.find((route) => route.name === NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR);
Expand Down Expand Up @@ -219,7 +220,7 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
adaptedState: getRoutesWithIndex(routes),
};
}
if (WorkspaceNavigator) {
if (workspaceNavigator) {
// Routes
// - default bottom tab
// - default central pane on desktop layout
Expand All @@ -238,7 +239,7 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
),
);

routes.push(WorkspaceNavigator);
routes.push(workspaceNavigator);

return {
adaptedState: getRoutesWithIndex(routes),
Expand Down Expand Up @@ -271,6 +272,19 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
}

// We need to make sure that this if only handles states where we deeplink to the bottom tab directly

// If policyID is defined, it should be passed to the reportNavigator params.
if (reportNavigator && policyID) {
const routes = [];
const reportNavigatorWithPolicyID = {...reportNavigator};
reportNavigatorWithPolicyID.params = {...reportNavigatorWithPolicyID.params, policyID};
routes.push(reportNavigatorWithPolicyID);

return {
adaptedState: getRoutesWithIndex(routes),
};
}

return {
adaptedState: state,
};
Expand Down

0 comments on commit eba231e

Please sign in to comment.