|
1 | | -import {useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native'; |
| 1 | +import {findFocusedRoute, useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native'; |
2 | 2 | import type {ContentStyle} from '@shopify/flash-list'; |
3 | 3 | import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; |
4 | 4 | import type {NativeScrollEvent, NativeSyntheticEvent, ViewToken} from 'react-native'; |
@@ -41,10 +41,11 @@ import { |
41 | 41 | shouldShowYear as shouldShowYearUtil, |
42 | 42 | } from '@libs/SearchUIUtils'; |
43 | 43 | import {isOnHold, isTransactionPendingDelete} from '@libs/TransactionUtils'; |
44 | | -import Navigation from '@navigation/Navigation'; |
| 44 | +import Navigation, {navigationRef} from '@navigation/Navigation'; |
45 | 45 | import type {SearchFullscreenNavigatorParamList} from '@navigation/types'; |
46 | 46 | import EmptySearchView from '@pages/Search/EmptySearchView'; |
47 | 47 | import CONST from '@src/CONST'; |
| 48 | +import NAVIGATORS from '@src/NAVIGATORS'; |
48 | 49 | import ONYXKEYS from '@src/ONYXKEYS'; |
49 | 50 | import ROUTES from '@src/ROUTES'; |
50 | 51 | import SCREENS from '@src/SCREENS'; |
@@ -236,10 +237,8 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS |
236 | 237 | }, [isSmallScreenWidth, selectedTransactions, isMobileSelectionModeEnabled]); |
237 | 238 |
|
238 | 239 | useEffect(() => { |
239 | | - const activeRoute = Navigation.getActiveRoute(); |
240 | | - const screenParamMatch = activeRoute.match(/screen=([^&]+)/); |
241 | | - const screenParam = screenParamMatch ? decodeURIComponent(screenParamMatch[1]) : null; |
242 | | - const isMigratedModalDisplayed = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; |
| 240 | + const focusedRoute = findFocusedRoute(navigationRef.getRootState()); |
| 241 | + const isMigratedModalDisplayed = focusedRoute?.name === NAVIGATORS.MIGRATED_USER_MODAL_NAVIGATOR || focusedRoute?.name === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; |
243 | 242 |
|
244 | 243 | if ((!isFocused && !isMigratedModalDisplayed) || isOffline) { |
245 | 244 | return; |
|
0 commit comments