From a24d9f034ea6ca3d4be4bf9fca4bcdb2a74112e1 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 8 Nov 2023 00:17:58 +0700 Subject: [PATCH 1/2] fix: 30988 New dot opens when navigate to the staging magic link, not abracadabra page --- .../createCustomStackNavigator/index.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index 194b8625910..ec38aa35420 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -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) { @@ -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. - 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]); From a253dfc8cbd903c3f0183cd3607266c3bdb00a50 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 8 Nov 2023 00:44:30 +0700 Subject: [PATCH 2/2] add comment --- .../AppNavigator/createCustomStackNavigator/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index ec38aa35420..8924b01e2ac 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -29,8 +29,11 @@ const defaultProps = { function reduceReportRoutes(routes) { const result = []; let count = 0; - routes.forEach((route) => { + const reverseRoutes = [...routes].reverse(); + + reverseRoutes.forEach((route) => { if (route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { + // Remove all report routes except the last 3. This will improve performance. if (count < 3) { result.push(route); count++; @@ -40,7 +43,7 @@ function reduceReportRoutes(routes) { } }); - return result; + return result.reverse(); } function ResponsiveStackNavigator(props) {