Skip to content

Commit

Permalink
Merge pull request #33829 from tienifr/fix/33417
Browse files Browse the repository at this point in the history
fix: Browser back button takes to previous modal while modal back button closes it
  • Loading branch information
jasperhuangg authored Jan 3, 2024
2 parents a83eecc + 687ace9 commit b57f6e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ function openReportFromDeepLink(url: string, isAuthenticated: boolean) {
return;
}
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route)) {
Session.signOutAndRedirectToSignIn();
Session.signOutAndRedirectToSignIn(true);
return;
}

Expand Down
8 changes: 6 additions & 2 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function isAnonymousUser(): boolean {
return sessionAuthTokenType === 'anonymousAccount';
}

function signOutAndRedirectToSignIn() {
function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean) {
Log.info('Redirecting to Sign In because signOut() was called');
hideContextMenu(false);
if (!isAnonymousUser()) {
Expand All @@ -110,7 +110,11 @@ function signOutAndRedirectToSignIn() {
if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) {
return;
}
Navigation.navigate(ROUTES.SIGN_IN_MODAL);
if (shouldReplaceCurrentScreen) {
Navigation.navigate(ROUTES.SIGN_IN_MODAL, CONST.NAVIGATION.TYPE.UP);
} else {
Navigation.navigate(ROUTES.SIGN_IN_MODAL);
}
Linking.getInitialURL().then((url) => {
const reportID = ReportUtils.getReportIDFromLink(url);
if (reportID) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/signin/SignInModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function SignInModal() {
shouldEnableMaxHeight
testID={SignInModal.displayName}
>
<HeaderWithBackButton onBackButtonPress={Navigation.dismissModal} />
<HeaderWithBackButton />
<SignInPage isInModal />
</ScreenWrapper>
);
Expand Down

0 comments on commit b57f6e0

Please sign in to comment.