Skip to content

Commit

Permalink
make sure report is added when visiting report attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Feb 23, 2024
1 parent 4a885f5 commit d3a6c18
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {NavigationState, PartialState} from '@react-navigation/native';
import type {NavigationState, PartialState, Route} from '@react-navigation/native';
import {getStateFromPath} from '@react-navigation/native';
import {isAnonymousUser} from '@libs/actions/Session';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
Expand Down Expand Up @@ -151,6 +151,8 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
const fullScreenNavigator = state.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_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 reportAttachmentsScreen = state.routes.find((route) => route.name === SCREENS.REPORT_ATTACHMENTS);

if (rhpNavigator) {
// Routes
// - matching bottom tab
Expand Down Expand Up @@ -257,6 +259,26 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
metainfo,
};
}
if (reportAttachmentsScreen) {
// Routes
// - matching bottom tab
// - central pane (report screen) of the attachment
// - found report attachments
const routes = [];
const reportAttachments = reportAttachmentsScreen as Route<'ReportAttachments', RootStackParamList['ReportAttachments']>;

const matchingBottomTabRoute = getMatchingBottomTabRouteForState(state);
routes.push(createBottomTabNavigator(matchingBottomTabRoute, policyID));
if (!isNarrowLayout) {
routes.push(createCentralPaneNavigator({name: SCREENS.REPORT, params: {reportID: reportAttachments.params?.reportID ?? ''}}));
}
routes.push(reportAttachments);

return {
adaptedState: getRoutesWithIndex(routes),
metainfo,
};
}
if (bottomTabNavigator) {
// Routes
// - found bottom tab
Expand Down

0 comments on commit d3a6c18

Please sign in to comment.