From 1e0adf934290f8227d0f0ee1eea6c37576cadae8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 17 Apr 2024 12:19:34 +0800 Subject: [PATCH 1/3] get the last bottom tab navigator --- src/libs/Navigation/getTopmostBottomTabRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/getTopmostBottomTabRoute.ts b/src/libs/Navigation/getTopmostBottomTabRoute.ts index a589f2cbc837..ff27d0e30ba6 100644 --- a/src/libs/Navigation/getTopmostBottomTabRoute.ts +++ b/src/libs/Navigation/getTopmostBottomTabRoute.ts @@ -1,7 +1,7 @@ import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types'; function getTopmostBottomTabRoute(state: State | undefined): NavigationPartialRoute | undefined { - const bottomTabNavigatorRoute = state?.routes[0]; + const bottomTabNavigatorRoute = state?.routes.findLast(route => route.name === 'BottomTabNavigator');; // The bottomTabNavigatorRoute state may be empty if we just logged in. if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) { From 5acf31c79878ec3c3b18801c74b7882290aa96c4 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 17 Apr 2024 13:18:44 +0800 Subject: [PATCH 2/3] prettier --- src/libs/Navigation/getTopmostBottomTabRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/getTopmostBottomTabRoute.ts b/src/libs/Navigation/getTopmostBottomTabRoute.ts index ff27d0e30ba6..e156b567af0d 100644 --- a/src/libs/Navigation/getTopmostBottomTabRoute.ts +++ b/src/libs/Navigation/getTopmostBottomTabRoute.ts @@ -1,7 +1,7 @@ import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types'; function getTopmostBottomTabRoute(state: State | undefined): NavigationPartialRoute | undefined { - const bottomTabNavigatorRoute = state?.routes.findLast(route => route.name === 'BottomTabNavigator');; + const bottomTabNavigatorRoute = state?.routes.findLast((route) => route.name === 'BottomTabNavigator'); // The bottomTabNavigatorRoute state may be empty if we just logged in. if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) { From 671039d8219171fc668506be52ae2274c0011076 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 17 Apr 2024 21:04:39 +0800 Subject: [PATCH 3/3] use const --- src/libs/Navigation/getTopmostBottomTabRoute.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/getTopmostBottomTabRoute.ts b/src/libs/Navigation/getTopmostBottomTabRoute.ts index e156b567af0d..48a8d80f4096 100644 --- a/src/libs/Navigation/getTopmostBottomTabRoute.ts +++ b/src/libs/Navigation/getTopmostBottomTabRoute.ts @@ -1,10 +1,11 @@ +import NAVIGATORS from '@src/NAVIGATORS'; import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types'; function getTopmostBottomTabRoute(state: State | undefined): NavigationPartialRoute | undefined { - const bottomTabNavigatorRoute = state?.routes.findLast((route) => route.name === 'BottomTabNavigator'); + const bottomTabNavigatorRoute = state?.routes.findLast((route) => route.name === NAVIGATORS.BOTTOM_TAB_NAVIGATOR); // The bottomTabNavigatorRoute state may be empty if we just logged in. - if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) { + if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== NAVIGATORS.BOTTOM_TAB_NAVIGATOR || bottomTabNavigatorRoute.state === undefined) { return undefined; }