From f6bfbf0e48bc2a4967483eb7f0ebe2c7a099e22f Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 19 Jan 2024 12:24:03 +0100 Subject: [PATCH] Refactor switching workspace --- src/libs/Navigation/Navigation.ts | 5 ++++- src/pages/WorkspaceSwitcherPage.js | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 72bb66b3df8e..5f6386e1e501 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -311,7 +311,10 @@ function waitForProtectedRoutes() { } function navigateWithSwitchPolicyID(policyID: string) { - goBack(); + if (!canNavigate('navigateWithSwitchPolicyID')) { + return; + } + return switchPolicyID(navigationRef.current, policyID); } diff --git a/src/pages/WorkspaceSwitcherPage.js b/src/pages/WorkspaceSwitcherPage.js index c5cebd8b3401..6369419e79d2 100644 --- a/src/pages/WorkspaceSwitcherPage.js +++ b/src/pages/WorkspaceSwitcherPage.js @@ -111,10 +111,8 @@ function WorkspaceSwitcherPage({policies}) { setSelectedOption(undefined); } setActiveWorkspaceID(policyID); - - if (policyID === activeWorkspaceID) { - Navigation.goBack(); - } else { + Navigation.goBack(); + if (policyID !== activeWorkspaceID) { Navigation.navigateWithSwitchPolicyID(policyID); } }, []);