From 6afbf9a3072ef1012c0130dc79ce22b309f1b283 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 16 Apr 2024 15:40:28 +0700 Subject: [PATCH 1/4] fix Unsynchronized transition of left and right page when deleting workspace --- src/pages/workspace/WorkspaceInitialPage.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index a6a131f5372c..1f00e2fe58cc 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -247,6 +247,12 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r // We check isPendingDelete for both policy and prevPolicy to prevent the NotFound view from showing right after we delete the workspace (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)); + useEffect(() => { + if (!isEmptyObject(prevPolicy) && !PolicyUtils.isPendingDeletePolicy(prevPolicy) && PolicyUtils.isPendingDeletePolicy(policy)) { + Navigation.navigateWithSwitchPolicyID({policyID: undefined}); + } + }, [policy, prevPolicy]); + // We are checking if the user can access the route. // If user can't access the route, we are dismissing any modals that are open when the NotFound view is shown const canAccessRoute = activeRoute && menuItems.some((item) => item.routeName === activeRoute); @@ -298,6 +304,8 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r onClose={() => dismissError(policyID)} errors={policy?.errors} errorRowStyles={[styles.ph5, styles.pv2]} + shouldDisableStrikeThrough={false} + shouldHideOnDelete={false} > {/* From d1ce7356e042390ee716fe6bc0ccf76b7a97019e Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 16 Apr 2024 16:28:25 +0700 Subject: [PATCH 2/4] fix navigate issue --- src/pages/workspace/WorkspaceInitialPage.tsx | 2 +- src/pages/workspace/WorkspaceProfilePage.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 1f00e2fe58cc..9acdc3f673da 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -249,7 +249,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r useEffect(() => { if (!isEmptyObject(prevPolicy) && !PolicyUtils.isPendingDeletePolicy(prevPolicy) && PolicyUtils.isPendingDeletePolicy(policy)) { - Navigation.navigateWithSwitchPolicyID({policyID: undefined}); + PolicyUtils.goBackFromInvalidPolicy(); } }, [policy, prevPolicy]); diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index 662335d0b358..b73c6c0d7062 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -97,7 +97,6 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi } Policy.deleteWorkspace(policy?.id, policyName); - PolicyUtils.goBackFromInvalidPolicy(); setIsDeleteModalOpen(false); // If the workspace being deleted is the active workspace, switch to the "All Workspaces" view From 804801138dd61f58f9d34c10f94710d80559cf8c Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 16 Apr 2024 16:38:54 +0700 Subject: [PATCH 3/4] fix lint --- src/pages/workspace/WorkspaceInitialPage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 9acdc3f673da..7a627ae5015d 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -248,9 +248,10 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)); useEffect(() => { - if (!isEmptyObject(prevPolicy) && !PolicyUtils.isPendingDeletePolicy(prevPolicy) && PolicyUtils.isPendingDeletePolicy(policy)) { - PolicyUtils.goBackFromInvalidPolicy(); + if (isEmptyObject(prevPolicy) || PolicyUtils.isPendingDeletePolicy(prevPolicy) || !PolicyUtils.isPendingDeletePolicy(policy)) { + return; } + PolicyUtils.goBackFromInvalidPolicy(); }, [policy, prevPolicy]); // We are checking if the user can access the route. From e0e1eba7f59dfdea2d8857f6574c316f28a92f09 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 19 Apr 2024 14:44:03 +0700 Subject: [PATCH 4/4] fix conflict --- src/pages/workspace/WorkspaceInitialPage.tsx | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index a18f9feda1f4..2f32034391a5 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -269,20 +269,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, reimbursementAcc PolicyUtils.goBackFromInvalidPolicy(); }, [policy, prevPolicy]); - // We are checking if the user can access the route. - // If user can't access the route, we are dismissing any modals that are open when the NotFound view is shown - const canAccessRoute = activeRoute && menuItems.some((item) => item.routeName === activeRoute); - - useEffect(() => { - if (!shouldShowNotFoundPage && canAccessRoute) { - return; - } - // We are dismissing any modals that are open when the NotFound view is shown - Navigation.isNavigationReady().then(() => { - Navigation.dismissRHP(); - }); - }, [canAccessRoute, policy, shouldShowNotFoundPage]); - const policyAvatar = useMemo(() => { if (!policy) { return {source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR};