Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] fix: 30988 New dot opens when navigate to the staging magic link, not abracadabra page #31014

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,21 @@ const defaultProps = {
screenOptions: undefined,
};

function splitRoutes(routes) {
const reportRoutes = [];
const rhpRoutes = [];
const otherRoutes = [];

function reduceReportRoutes(routes) {
const result = [];
let count = 0;
routes.forEach((route) => {
if (route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) {
reportRoutes.push(route);
} else if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
rhpRoutes.push(route);
if (count < 3) {
result.push(route);
count++;
}
} else {
otherRoutes.push(route);
result.push(route);
}
});

return {reportRoutes, rhpRoutes, otherRoutes};
return result;
}

function ResponsiveStackNavigator(props) {
Expand All @@ -60,15 +59,12 @@ function ResponsiveStackNavigator(props) {
});

const stateToRender = useMemo(() => {
const {reportRoutes, rhpRoutes, otherRoutes} = splitRoutes(state.routes);

// Remove all report routes except the last 3. This will improve performance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep this comment but just move to here

const limitedReportRoutes = reportRoutes.slice(-3);
const result = reduceReportRoutes(state.routes);

return {
...state,
index: otherRoutes.length + limitedReportRoutes.length + rhpRoutes.length - 1,
routes: [...otherRoutes, ...limitedReportRoutes, ...rhpRoutes],
index: result.length - 1,
routes: [...result],
};
}, [state]);

Expand Down
Loading