Skip to content

Commit

Permalink
Remove Navigation.switchPolicyID
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Nov 29, 2024
1 parent 5f96fb6 commit 60d4895
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,6 @@ function waitForProtectedRoutes() {
});
}

function switchPolicyID(policyID?: string) {
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.SWITCH_POLICY_ID, payload: {policyID}});
}

type NavigateToReportWithPolicyCheckPayload = {report?: OnyxEntry<Report>; reportID?: string; reportActionID?: string; referrer?: string; policyIDToCheck?: string};

function navigateToReportWithPolicyCheck({report, reportID, reportActionID, referrer, policyIDToCheck}: NavigateToReportWithPolicyCheckPayload, ref = navigationRef) {
Expand Down Expand Up @@ -499,7 +495,6 @@ export default {
getTopmostReportActionId,
waitForProtectedRoutes,
parseHybridAppUrl,
switchPolicyID,
resetToHome,
closeRHPFlow,
setNavigationActionToMicrotaskQueue,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/WorkspaceSwitcherPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import Navigation, {navigationRef} from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import {sortWorkspacesBySelected} from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -92,7 +92,7 @@ function WorkspaceSwitcherPage() {

Navigation.goBack();
if (policyID !== activeWorkspaceID) {
Navigation.switchPolicyID(policyID);
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.SWITCH_POLICY_ID, payload: {policyID}});
}
},
[activeWorkspaceID],
Expand Down
7 changes: 5 additions & 2 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ function BaseSidebarScreen() {
Timing.start(CONST.TIMING.SIDEBAR_LOADED);
}, []);

// If the selected workspace has been deleted, the current workspace is reset to global.
useEffect(() => {
if (!!activeWorkspace || activeWorkspaceID === undefined) {
const isActiveWorkspaceDeleted = !!activeWorkspace || activeWorkspaceID === undefined;

if (isActiveWorkspaceDeleted) {
return;
}

Expand All @@ -58,7 +61,7 @@ function BaseSidebarScreen() {
navigationRef.current?.dispatch({
target: navigationRef.current.getRootState().key,
payload: createSplitNavigator({name: SCREENS.HOME}, {name: SCREENS.REPORT}),
type: 'REPLACE',
type: CONST.NAVIGATION.ACTION_TYPE.REPLACE,
});
}
}, [activeWorkspace, activeWorkspaceID, currentRoute]);
Expand Down

0 comments on commit 60d4895

Please sign in to comment.