mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 15:56:10 +08:00
fix(preference-accounts): Don't select accounts that no longer exist
Summary: After updating an account's connection settings, there's a brief moment where the selected account isn't null, but doesn't actually exist in the AccountStore. This throws a bunch of undefined errors, so this diff makes sure we discard that selection. Fixes T7452 Test Plan: tested locally Reviewers: evan, juan Reviewed By: juan Maniphest Tasks: T7452 Differential Revision: https://phab.nylas.com/D3634
This commit is contained in:
parent
71c00776ff
commit
bd842ee73a
|
@ -26,9 +26,18 @@ class PreferencesAccounts extends React.Component {
|
|||
|
||||
getStateFromStores({selected} = {}) {
|
||||
const accounts = AccountStore.accounts()
|
||||
let selectedAccount;
|
||||
if (selected) {
|
||||
selectedAccount = _.findWhere(accounts, {id: selected.id})
|
||||
}
|
||||
// If selected was null or no longer exists in the AccountStore,
|
||||
// just use the first account.
|
||||
if (!selectedAccount) {
|
||||
selectedAccount = accounts[0];
|
||||
}
|
||||
return {
|
||||
accounts,
|
||||
selected: selected ? _.findWhere(accounts, {id: selected.id}) : accounts[0],
|
||||
selected: selectedAccount,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue