From 97c61b43bc27d3f437245d5fca9dcdf26f22378e Mon Sep 17 00:00:00 2001 From: Greg Price Date: Mon, 8 Jul 2019 17:55:23 -0700 Subject: [PATCH] WIP WIP use own-email from /register rather than auth This probably doesn't totally work as is -- there are probably some places we want the email before we have the /register response, as well as places we want the delivery_email. But I think it's the core of the fix to #3196. --- src/account/accountsSelectors.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/account/accountsSelectors.js b/src/account/accountsSelectors.js index e10a6a7de51..9c1a3c0d44c 100644 --- a/src/account/accountsSelectors.js +++ b/src/account/accountsSelectors.js @@ -64,7 +64,13 @@ export const getActiveAccount = (state: GlobalState): Account => { }; /** The user's own email in the active account; throws if none. */ -export const getOwnEmail = (state: GlobalState): string => getActiveAccount(state).email; +export const getOwnEmail = (state: GlobalState): string => { + const { email } = state.realm; + if (email === undefined) { + throw new Error('No server data found'); + } + return email; +}; /** The realm of the active account; throws if none. */ export const getCurrentRealm = (state: GlobalState) => getActiveAccount(state).realm;