Skip to content

Commit

Permalink
Replace some usages of resetToHome with goUp(ROUTES.HOME)
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Oct 7, 2024
1 parent 9d9f80d commit e0f61ec
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string | undefined>, minimalAction.payload.params as Record<string, string | undefined>);
}

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function CardSection() {
const requestRefund = useCallback(() => {
User.requestRefund();
setIsRequestRefundModalVisible(false);
Navigation.resetToHome();
Navigation.goUp(ROUTES.HOME);
}, []);

const viewPurchases = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/AccessOrNotFoundWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
>
<FullPageNotFoundView
onBackButtonPress={Navigation.dismissModal}
onLinkPress={Navigation.resetToHome}
onLinkPress={() => Navigation.goUp(ROUTES.HOME)}
shouldShow={shouldShowNotFoundPage}
subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}
>
<HeaderWithBackButton
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);
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -173,8 +174,8 @@ function WorkspacePageWithSections({
shouldShowOfflineIndicatorInWideScreen={shouldShowOfflineIndicatorInWideScreen && !shouldShow}
>
<FullPageNotFoundView
onBackButtonPress={Navigation.dismissModal}
onLinkPress={Navigation.resetToHome}
onBackButtonPress={() => Navigation.goUp(ROUTES.SETTINGS_WORKSPACES)}
onLinkPress={() => Navigation.goUp(ROUTES.HOME)}
shouldShow={shouldShow}
subtitleKey={isEmptyObject(policy) ? undefined : 'workspace.common.notAuthorized'}
shouldForceFullScreen
Expand Down

0 comments on commit e0f61ec

Please sign in to comment.