Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Nov 22, 2023
1 parent 04a81cc commit 370dafb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function navigate(route = ROUTES.HOME, type) {
pendingRoute = route;
return;
}
linkTo(navigationRef.current, route, type);
linkTo(navigationRef.current, route, type, isActiveRoute(route));

Check failure on line 114 in src/libs/Navigation/Navigation.js

View workflow job for this annotation

GitHub Actions / lint

'isActiveRoute' was used before it was defined
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/linkTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function getMinimalAction(action, state) {
return currentAction;
}

export default function linkTo(navigation, path, type) {
export default function linkTo(navigation, path, type, isActiveRoute) {
if (navigation === undefined) {
throw new Error("Couldn't find a navigation object. Is your component inside a screen in a navigator?");
}
Expand Down Expand Up @@ -86,7 +86,7 @@ export default function linkTo(navigation, path, type) {
// There are situations where a route already exists on the current navigation stack
// But we want to push the same route instead of going back in the stack
// Which would break the user navigation history
if (type === CONST.NAVIGATION.ACTION_TYPE.PUSH) {
if (!isActiveRoute && type === CONST.NAVIGATION.ACTION_TYPE.PUSH) {
minimalAction.type = CONST.NAVIGATION.ACTION_TYPE.PUSH;
}
// There are situations when the user is trying to access a route which he has no access to
Expand Down
4 changes: 1 addition & 3 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,7 @@ function openReportFromDeepLink(url, isAuthenticated) {
Session.signOutAndRedirectToSignIn();
return;
}
if (!Navigation.isActiveRoute(route)) {
Navigation.navigate(route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
}
Navigation.navigate(route, CONST.NAVIGATION.ACTION_TYPE.PUSH);
});
});
});
Expand Down

0 comments on commit 370dafb

Please sign in to comment.