Skip to content

Commit f607a68

Browse files
nkuochOSBotify
authored andcommitted
Merge pull request #31014 from tienifr/fix/30988
fix: 30988 New dot opens when navigate to the staging magic link, not abracadabra page (cherry picked from commit 217b2cf)
1 parent b857115 commit f607a68

File tree

1 file changed

+15
-16
lines changed
  • src/libs/Navigation/AppNavigator/createCustomStackNavigator

1 file changed

+15
-16
lines changed

src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ const defaultProps = {
2626
screenOptions: undefined,
2727
};
2828

29-
function splitRoutes(routes) {
30-
const reportRoutes = [];
31-
const rhpRoutes = [];
32-
const otherRoutes = [];
29+
function reduceReportRoutes(routes) {
30+
const result = [];
31+
let count = 0;
32+
const reverseRoutes = [...routes].reverse();
3333

34-
routes.forEach((route) => {
34+
reverseRoutes.forEach((route) => {
3535
if (route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) {
36-
reportRoutes.push(route);
37-
} else if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
38-
rhpRoutes.push(route);
36+
// Remove all report routes except the last 3. This will improve performance.
37+
if (count < 3) {
38+
result.push(route);
39+
count++;
40+
}
3941
} else {
40-
otherRoutes.push(route);
42+
result.push(route);
4143
}
4244
});
4345

44-
return {reportRoutes, rhpRoutes, otherRoutes};
46+
return result.reverse();
4547
}
4648

4749
function ResponsiveStackNavigator(props) {
@@ -60,15 +62,12 @@ function ResponsiveStackNavigator(props) {
6062
});
6163

6264
const stateToRender = useMemo(() => {
63-
const {reportRoutes, rhpRoutes, otherRoutes} = splitRoutes(state.routes);
64-
65-
// Remove all report routes except the last 3. This will improve performance.
66-
const limitedReportRoutes = reportRoutes.slice(-3);
65+
const result = reduceReportRoutes(state.routes);
6766

6867
return {
6968
...state,
70-
index: otherRoutes.length + limitedReportRoutes.length + rhpRoutes.length - 1,
71-
routes: [...otherRoutes, ...limitedReportRoutes, ...rhpRoutes],
69+
index: result.length - 1,
70+
routes: [...result],
7271
};
7372
}, [state]);
7473

0 commit comments

Comments
 (0)