Skip to content

Commit

Permalink
Prevent app from crash when putting app in background from ND
Browse files Browse the repository at this point in the history
  • Loading branch information
jnowakow committed Jan 9, 2025
1 parent 0051853 commit fc8cb33
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {findFocusedRoute, StackActions} from '@react-navigation/native';
import {BackHandler, NativeModules} from 'react-native';
import {BackHandler} from 'react-native';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import getTopmostCentralPaneRoute from '@navigation/getTopmostCentralPaneRoute';
import navigationRef from '@navigation/navigationRef';
Expand All @@ -22,12 +22,6 @@ function setupCustomAndroidBackHandler() {
return false;
}

const isLastScreenOnStack = bottomTabRoutes.length === 1 && rootState?.routes?.length === 1;

if (NativeModules.HybridAppModule && isLastScreenOnStack) {
NativeModules.HybridAppModule.exitApp();
}

// Handle back press on the search page.
// We need to pop two screens, from the central pane and from the bottom tab.
if (bottomTabRoutes[bottomTabRoutes.length - 1].name === SCREENS.SEARCH.BOTTOM_TAB && focusedRoute?.name === SCREENS.SEARCH.CENTRAL_PANE) {
Expand Down

0 comments on commit fc8cb33

Please sign in to comment.