@@ -2,8 +2,7 @@ import type {CommonActions, RouterConfigOptions, StackActionType, StackNavigatio
2
2
import { StackActions } from '@react-navigation/native' ;
3
3
import type { ParamListBase , Router } from '@react-navigation/routers' ;
4
4
import Log from '@libs/Log' ;
5
- import getPolicyIDFromState from '@libs/Navigation/helpers/getPolicyIDFromState' ;
6
- import type { RootNavigatorParamList , State } from '@libs/Navigation/types' ;
5
+ import type { RootNavigatorParamList } from '@libs/Navigation/types' ;
7
6
import * as SearchQueryUtils from '@libs/SearchQueryUtils' ;
8
7
import NAVIGATORS from '@src/NAVIGATORS' ;
9
8
import SCREENS from '@src/SCREENS' ;
@@ -29,7 +28,7 @@ const MODAL_ROUTES_TO_DISMISS: string[] = [
29
28
const workspaceSplitsWithoutEnteringAnimation = new Set < string > ( ) ;
30
29
const reportsSplitsWithEnteringAnimation = new Set < string > ( ) ;
31
30
const settingsSplitWithEnteringAnimation = new Set < string > ( ) ;
32
-
31
+ const searchFullscreenWithEnteringAnimation = new Set < string > ( ) ;
33
32
/**
34
33
* Handles the OPEN_WORKSPACE_SPLIT action.
35
34
* If the user is on other tab than settings and the workspace split is "remembered", this action will be called after pressing the settings tab.
@@ -202,44 +201,23 @@ function handlePushSearchPageAction(
202
201
action : PushActionType ,
203
202
configOptions : RouterConfigOptions ,
204
203
stackRouter : Router < StackNavigationState < ParamListBase > , CommonActions . Action | StackActionType > ,
205
- setActiveWorkspaceID : ( workspaceID : string | undefined ) => void ,
206
204
) {
207
- let updatedAction = action ;
208
- const currentParams = action . payload . params as RootNavigatorParamList [ typeof NAVIGATORS . SEARCH_FULLSCREEN_NAVIGATOR ] ;
209
- if ( currentParams ?. screen === SCREENS . SEARCH . ROOT ) {
210
- const searchParams = currentParams ?. params ;
211
- const queryJSON = SearchQueryUtils . buildSearchQueryJSON ( searchParams . q ) ;
212
- if ( ! queryJSON ) {
213
- return null ;
214
- }
205
+ const stateWithSearchFullscreenNavigator = stackRouter . getStateForAction ( state , action , configOptions ) ;
215
206
216
- if ( ! queryJSON . policyID ) {
217
- const policyID = getPolicyIDFromState ( state as State < RootNavigatorParamList > ) ;
207
+ if ( ! stateWithSearchFullscreenNavigator ) {
208
+ Log . hmmm ( '[handlePushSettingsAction] SearchFullscreenNavigator has not been found in the navigation state.' ) ;
209
+ return null ;
210
+ }
218
211
219
- if ( policyID ) {
220
- queryJSON . policyID = policyID ;
221
- } else {
222
- delete queryJSON . policyID ;
223
- }
224
- } else {
225
- setActiveWorkspaceID ( queryJSON . policyID ) ;
226
- }
212
+ const lastFullScreenRoute = stateWithSearchFullscreenNavigator . routes . at ( - 1 ) ;
213
+ const actionPayloadScreen = action . payload ?. params && 'screen' in action . payload . params ? action . payload ?. params ?. screen : undefined ;
227
214
228
- updatedAction = {
229
- ...action ,
230
- payload : {
231
- ...action . payload ,
232
- params : {
233
- ...action . payload . params ,
234
- params : {
235
- q : SearchQueryUtils . buildSearchQueryString ( queryJSON ) ,
236
- } ,
237
- } ,
238
- } ,
239
- } ;
215
+ // Transitioning to SCREENS.SEARCH.MONEY_REQUEST_REPORT should be animated
216
+ if ( actionPayloadScreen === SCREENS . SEARCH . MONEY_REQUEST_REPORT && lastFullScreenRoute ?. key ) {
217
+ searchFullscreenWithEnteringAnimation . add ( lastFullScreenRoute . key ) ;
240
218
}
241
219
242
- return stackRouter . getStateForAction ( state , updatedAction , configOptions ) ;
220
+ return stateWithSearchFullscreenNavigator ;
243
221
}
244
222
245
223
function handleReplaceReportsSplitNavigatorAction (
@@ -309,6 +287,7 @@ export {
309
287
handleSwitchPolicyIDAction ,
310
288
handleSwitchPolicyIDFromSearchAction ,
311
289
reportsSplitsWithEnteringAnimation ,
290
+ searchFullscreenWithEnteringAnimation ,
312
291
settingsSplitWithEnteringAnimation ,
313
292
workspaceSplitsWithoutEnteringAnimation ,
314
293
} ;
0 commit comments