Skip to content

Commit

Permalink
Exclude switchPolicyID logic to navigation helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Jan 17, 2025
1 parent 6105b7b commit d6bb5c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import isReportOpenInRHP from './helpers/isReportOpenInRHP';
import linkTo from './helpers/linkTo';
import getMinimalAction from './helpers/linkTo/getMinimalAction';
import setNavigationActionToMicrotaskQueue from './helpers/setNavigationActionToMicrotaskQueue';
import switchPolicyID from './helpers/switchPolicyID';
import {linkingConfig} from './linkingConfig';
import navigationRef from './navigationRef';
import type {NavigationPartialRoute, NavigationStateRoute, RootNavigatorParamList, State} from './types';
Expand Down Expand Up @@ -548,6 +549,7 @@ export default {
navigateToReportWithPolicyCheck,
popToTop,
removeScreenFromNavigationState,
switchPolicyID,
};

export {navigationRef};
6 changes: 6 additions & 0 deletions src/libs/Navigation/helpers/switchPolicyID.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import navigationRef from '@libs/Navigation/navigationRef';
import CONST from '@src/CONST';

export default function switchPolicyID(newPolicyID: string | undefined) {
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.SWITCH_POLICY_ID, payload: {policyID: newPolicyID}});
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {InteractionManager} from 'react-native';
import {navigationRef} from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import Navigation from '@libs/Navigation/Navigation';

function switchPolicyAfterInteractions(newPolicyID: string | undefined) {
InteractionManager.runAfterInteractions(() => {
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.SWITCH_POLICY_ID, payload: {policyID: newPolicyID}});
Navigation.switchPolicyID(newPolicyID);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {navigationRef} from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import Navigation from '@libs/Navigation/Navigation';

function switchPolicyAfterInteractions(newPolicyID: string | undefined) {
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.SWITCH_POLICY_ID, payload: {policyID: newPolicyID}});
Navigation.switchPolicyID(newPolicyID);
}

export default switchPolicyAfterInteractions;

0 comments on commit d6bb5c3

Please sign in to comment.