From 687ace9eae81f046072fdde8f123ac6a9f24aa51 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 2 Jan 2024 15:35:13 +0700 Subject: [PATCH] fix: Browser back button takes to previous modal while modal back button closes it --- src/libs/actions/Report.ts | 2 +- src/libs/actions/Session/index.ts | 8 ++++++-- src/pages/signin/SignInModal.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 06c0316a40b5..c77fea74b454 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2029,7 +2029,7 @@ function openReportFromDeepLink(url: string, isAuthenticated: boolean) { return; } if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route)) { - Session.signOutAndRedirectToSignIn(); + Session.signOutAndRedirectToSignIn(true); return; } diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index ca38e0dd5902..a667e054fb92 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -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()) { @@ -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) { diff --git a/src/pages/signin/SignInModal.js b/src/pages/signin/SignInModal.js index 10f048d31380..df266b557ced 100644 --- a/src/pages/signin/SignInModal.js +++ b/src/pages/signin/SignInModal.js @@ -29,7 +29,7 @@ function SignInModal() { shouldEnableMaxHeight testID={SignInModal.displayName} > - + );