From 016ba6ac96d173daf52ae0e7a104809002a50754 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 20 Oct 2020 13:29:10 -0700 Subject: [PATCH] InitialNavigationDispatcher: Clarify and improve `doInitialNavigation`. When the active account isn't logged in and there's just one account in total, we can reasonably pre-fill that account's realm in the realm-input screen. It seems like this has been the expected behavior [1], but I just tested it now, and it hasn't been happening. Also, for readability, separate the `accounts.length === 1` check into its own `else if`. [1] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/decouple.20nav.20from.20redux.20%28.23M3804%29/near/1042602 --- src/nav/InitialNavigationDispatcher.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/nav/InitialNavigationDispatcher.js b/src/nav/InitialNavigationDispatcher.js index 7dc73475652..dde72678b28 100644 --- a/src/nav/InitialNavigationDispatcher.js +++ b/src/nav/InitialNavigationDispatcher.js @@ -43,12 +43,26 @@ class InitialNavigationDispatcher extends PureComponent { doInitialNavigation = () => { const { hasAuth, accounts, haveServerData, dispatch } = this.props; - // If the active account is not logged in, show account screen. + // If the active account is not logged in, bring the user as close + // as we can to AuthScreen, the place where they can log in. if (!hasAuth) { if (accounts.length > 1) { + // We can't guess which account, of multiple, the user wants + // to use. Let them pick one. dispatch(resetToAccountPicker()); return; + } else if (accounts.length === 1) { + // We already know the realm, so give that to the realm + // screen. If that screen finds that the realm is valid, it'll + // send the user along to AuthScreen for that realm right + // away. If this means you're on the AuthScreen when you don't + // want to be (i.e., you want to choose a different realm), + // you can always go back to RealmScreen. + dispatch(resetToRealmScreen({ initial: true, realm: accounts[0].realm })); + return; } else { + // Just go to the realm screen and have the user type out the + // realm. dispatch(resetToRealmScreen({ initial: true })); return; }