Skip to content

Commit

Permalink
InitialNavigationDispatcher: Clarify and improve doInitialNavigation.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chrisbobbe committed Oct 21, 2020
1 parent 88eb0ed commit 016ba6a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/nav/InitialNavigationDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,26 @@ class InitialNavigationDispatcher extends PureComponent<Props> {
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;
}
Expand Down

0 comments on commit 016ba6a

Please sign in to comment.