From e0f61eca89ebb37603a119f360fa68447e1d3ade Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 7 Oct 2024 15:59:45 +0200 Subject: [PATCH] Replace some usages of resetToHome with goUp(ROUTES.HOME) --- src/libs/Navigation/Navigation.ts | 5 +++-- src/pages/settings/Subscription/CardSection/CardSection.tsx | 2 +- src/pages/workspace/AccessOrNotFoundWrapper.tsx | 2 +- src/pages/workspace/WorkspaceInitialPage.tsx | 4 ++-- src/pages/workspace/WorkspacePageWithSections.tsx | 5 +++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 8d8149b6f236..a7789a6b4f3e 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -225,6 +225,7 @@ function doesRouteMatchToMinimalActionPayload(route: NavigationStateRoute | Navi return false; } + // @TODO: Fix params comparison. When comparing split navigators params, it may happen that first one has parameters with the initial settings and the second one does not. return shallowCompare(route.params as Record, minimalAction.payload.params as Record); } @@ -233,8 +234,8 @@ function goUp(fallbackRoute: Route) { return; } - if (!navigationRef.current?.canGoBack()) { - Log.hmmm('[Navigation] Unable to go back'); + if (!navigationRef.current) { + Log.hmmm('[Navigation] Unable to go up'); return; } diff --git a/src/pages/settings/Subscription/CardSection/CardSection.tsx b/src/pages/settings/Subscription/CardSection/CardSection.tsx index 2cb99207f8e0..5290c20cbd72 100644 --- a/src/pages/settings/Subscription/CardSection/CardSection.tsx +++ b/src/pages/settings/Subscription/CardSection/CardSection.tsx @@ -57,7 +57,7 @@ function CardSection() { const requestRefund = useCallback(() => { User.requestRefund(); setIsRequestRefundModalVisible(false); - Navigation.resetToHome(); + Navigation.goUp(ROUTES.HOME); }, []); const viewPurchases = useCallback(() => { diff --git a/src/pages/workspace/AccessOrNotFoundWrapper.tsx b/src/pages/workspace/AccessOrNotFoundWrapper.tsx index 1a6f59830506..64110f9c95cd 100644 --- a/src/pages/workspace/AccessOrNotFoundWrapper.tsx +++ b/src/pages/workspace/AccessOrNotFoundWrapper.tsx @@ -91,7 +91,7 @@ function PageNotFoundFallback({policyID, shouldShowFullScreenFallback, fullPageN shouldForceFullScreen={shouldShowFullScreenFallback} onBackButtonPress={() => { if (shouldShowFullScreenFallback) { - Navigation.dismissModal(); + Navigation.goUp(ROUTES.SETTINGS_WORKSPACES); return; } Navigation.goBack(policyID && !isMoneyRequest ? ROUTES.WORKSPACE_PROFILE.getRoute(policyID) : undefined); diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 5fb36f86600c..236f89c46ba9 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -350,7 +350,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac > Navigation.goUp(ROUTES.HOME)} shouldShow={shouldShowNotFoundPage} subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'} > @@ -358,7 +358,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac title={policyName} onBackButtonPress={() => { if (route.params?.backTo) { - Navigation.resetToHome(); + Navigation.goUp(ROUTES.HOME); Navigation.isNavigationReady().then(() => Navigation.navigate(route.params?.backTo as Route)); } else { Navigation.goUp(ROUTES.SETTINGS_WORKSPACES); diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 4f0a84cffd9c..d7999971cca7 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -21,6 +21,7 @@ import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Route} from '@src/ROUTES'; +import ROUTES from '@src/ROUTES'; import type {Policy} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -173,8 +174,8 @@ function WorkspacePageWithSections({ shouldShowOfflineIndicatorInWideScreen={shouldShowOfflineIndicatorInWideScreen && !shouldShow} > Navigation.goUp(ROUTES.SETTINGS_WORKSPACES)} + onLinkPress={() => Navigation.goUp(ROUTES.HOME)} shouldShow={shouldShow} subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'} shouldForceFullScreen