From dfec2a4cb75fb3f8a3cfd7afe57446d98a41b313 Mon Sep 17 00:00:00 2001 From: sepeterson <10458078+sepeterson@users.noreply.github.com> Date: Tue, 10 Mar 2026 16:23:26 -0500 Subject: [PATCH] MOB-1190: move helper logic outside component --- .../CustomTabBarContainer.tsx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/navigation/BottomTabNavigator/CustomTabBarContainer.tsx b/src/navigation/BottomTabNavigator/CustomTabBarContainer.tsx index b16cae358..dc1e3a1e5 100644 --- a/src/navigation/BottomTabNavigator/CustomTabBarContainer.tsx +++ b/src/navigation/BottomTabNavigator/CustomTabBarContainer.tsx @@ -34,6 +34,22 @@ type ScreenName = type Props = BottomTabBarProps; +// Reset Menu and Notifications stacks when navigating away from them +const resetOnLeaveTabScreenTuples: [TabName, ScreenName][] = [ + ["MenuTab", SCREEN_NAME_MENU], + ["NotificationsTab", SCREEN_NAME_NOTIFICATIONS], +]; + +const getActiveTab = ( activeTabName: TabName ): ScreenName => { + switch ( activeTabName ) { + case "MenuTab": return SCREEN_NAME_MENU; + case "ExploreTab": return SCREEN_NAME_ROOT_EXPLORE; + case "ObservationsTab": return SCREEN_NAME_OBS_LIST; + case "NotificationsTab": return SCREEN_NAME_NOTIFICATIONS; + default: return SCREEN_NAME_OBS_LIST; + } +}; + const CustomTabBarContainer: React.FC = ( { navigation, state } ) => { const { t } = useTranslation( ); const currentUser = useCurrentUser( ); @@ -43,17 +59,7 @@ const CustomTabBarContainer: React.FC = ( { navigation, state } ) => { const userIconUri = useMemo( ( ) => User.uri( currentUser ), [currentUser] ); - const getActiveTab = ( ): ScreenName => { - switch ( activeTabName ) { - case "MenuTab": return SCREEN_NAME_MENU; - case "ExploreTab": return SCREEN_NAME_ROOT_EXPLORE; - case "ObservationsTab": return SCREEN_NAME_OBS_LIST; - case "NotificationsTab": return SCREEN_NAME_NOTIFICATIONS; - default: return SCREEN_NAME_OBS_LIST; - } - }; - - const activeTab = getActiveTab( ); + const activeTab = getActiveTab( activeTabName ); const handleTabPress = useCallback( ( targetTabName: TabName, @@ -64,13 +70,7 @@ const CustomTabBarContainer: React.FC = ( { navigation, state } ) => { = navState.routes.slice(); let needsReset = false; - // Reset Menu and Notifications stacks when navigating away from them - const resetOnLeave: [TabName, ScreenName][] = [ - ["MenuTab", SCREEN_NAME_MENU], - ["NotificationsTab", SCREEN_NAME_NOTIFICATIONS], - ]; - - for ( const [tabName, screenName] of resetOnLeave ) { + for ( const [tabName, screenName] of resetOnLeaveTabScreenTuples ) { if ( activeTabName === tabName && targetTabName !== tabName ) { const idx = newStacks.findIndex( r => r.name === activeTabName ); newStacks.splice( idx, 1, {