Skip to content

Commit 016ba6a

Browse files
committed
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
1 parent 88eb0ed commit 016ba6a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/nav/InitialNavigationDispatcher.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,26 @@ class InitialNavigationDispatcher extends PureComponent<Props> {
4343
doInitialNavigation = () => {
4444
const { hasAuth, accounts, haveServerData, dispatch } = this.props;
4545

46-
// If the active account is not logged in, show account screen.
46+
// If the active account is not logged in, bring the user as close
47+
// as we can to AuthScreen, the place where they can log in.
4748
if (!hasAuth) {
4849
if (accounts.length > 1) {
50+
// We can't guess which account, of multiple, the user wants
51+
// to use. Let them pick one.
4952
dispatch(resetToAccountPicker());
5053
return;
54+
} else if (accounts.length === 1) {
55+
// We already know the realm, so give that to the realm
56+
// screen. If that screen finds that the realm is valid, it'll
57+
// send the user along to AuthScreen for that realm right
58+
// away. If this means you're on the AuthScreen when you don't
59+
// want to be (i.e., you want to choose a different realm),
60+
// you can always go back to RealmScreen.
61+
dispatch(resetToRealmScreen({ initial: true, realm: accounts[0].realm }));
62+
return;
5163
} else {
64+
// Just go to the realm screen and have the user type out the
65+
// realm.
5266
dispatch(resetToRealmScreen({ initial: true }));
5367
return;
5468
}

0 commit comments

Comments
 (0)