From 66b2b2a54944fc2c5de5e7c6a1501c34047623c5 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 10 Jan 2024 18:37:20 -0500 Subject: [PATCH 1/5] remove redundant navigation --- src/pages/LogOutPreviousUserPage.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/pages/LogOutPreviousUserPage.js b/src/pages/LogOutPreviousUserPage.js index 9609f3f9bd56..68ff2ae935a8 100644 --- a/src/pages/LogOutPreviousUserPage.js +++ b/src/pages/LogOutPreviousUserPage.js @@ -53,16 +53,6 @@ function LogOutPreviousUserPage(props) { const shortLivedAuthToken = lodashGet(props, 'route.params.shortLivedAuthToken', ''); Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken); } - - const exitTo = lodashGet(props, 'route.params.exitTo', ''); - // We don't want to navigate to the exitTo route when creating a new workspace from a deep link, - // because we already handle creating the optimistic policy and navigating to it in App.setUpPoliciesAndNavigate, - // which is already called when AuthScreens mounts. - if (exitTo && exitTo !== ROUTES.WORKSPACE_NEW && !props.account.isLoading && !isLoggingInAsNewUser) { - Navigation.isNavigationReady().then(() => { - Navigation.navigate(exitTo); - }); - } }); }, [props]); From a425560f3ac2fff4b53ca86c1b5146b498cb2c66 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 10 Jan 2024 18:45:10 -0500 Subject: [PATCH 2/5] run the effect only once --- src/pages/LogOutPreviousUserPage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/LogOutPreviousUserPage.js b/src/pages/LogOutPreviousUserPage.js index 68ff2ae935a8..2ce4bc7bdd4f 100644 --- a/src/pages/LogOutPreviousUserPage.js +++ b/src/pages/LogOutPreviousUserPage.js @@ -54,7 +54,10 @@ function LogOutPreviousUserPage(props) { Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken); } }); - }, [props]); + + // We only want to run this effect once on mount (when the page first loads after transitioning from OldDot) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return ; } From d72498ebf9515690f1d84eebf358d434217a0e6c Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 10 Jan 2024 19:24:12 -0500 Subject: [PATCH 3/5] remove unused imports --- src/pages/LogOutPreviousUserPage.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/LogOutPreviousUserPage.js b/src/pages/LogOutPreviousUserPage.js index 2ce4bc7bdd4f..eb2d0188b9cb 100644 --- a/src/pages/LogOutPreviousUserPage.js +++ b/src/pages/LogOutPreviousUserPage.js @@ -5,10 +5,8 @@ import {Linking} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import * as SessionUtils from '@libs/SessionUtils'; -import Navigation from '@navigation/Navigation'; import * as Session from '@userActions/Session'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { /** The details about the account that the user is signing in with */ From 6a15e24d5dcc5769aa448d70b4b897c33be9a1e2 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 10 Jan 2024 19:51:57 -0500 Subject: [PATCH 4/5] use waitForProtectedRoutes --- src/libs/actions/App.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index c0691eb86475..7fb5a6c49a2b 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -413,7 +413,7 @@ function setUpPoliciesAndNavigate(session: OnyxEntry) { return; } if (!isLoggingInAsNewUser && exitTo) { - Navigation.isNavigationReady() + Navigation.waitForProtectedRoutes() .then(() => { // We must call goBack() to remove the /transition route from history Navigation.goBack(ROUTES.HOME); From dbc6f3b23c5b6874b929535591713a61a2a9069a Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 10 Jan 2024 21:01:46 -0500 Subject: [PATCH 5/5] add clarifying comment --- src/pages/LogOutPreviousUserPage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/LogOutPreviousUserPage.js b/src/pages/LogOutPreviousUserPage.js index eb2d0188b9cb..5c8a39204467 100644 --- a/src/pages/LogOutPreviousUserPage.js +++ b/src/pages/LogOutPreviousUserPage.js @@ -31,6 +31,10 @@ const defaultProps = { }, }; +// This page is responsible for handling transitions from OldDot. Specifically, it logs the current user +// out if the transition is for another user. +// +// This component should not do any other navigation as that handled in App.setUpPoliciesAndNavigate function LogOutPreviousUserPage(props) { useEffect(() => { Linking.getInitialURL().then((transitionURL) => {