mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
fix(aliases): Properly set selected state on account update
This commit is contained in:
parent
cf6428d94a
commit
18f0872794
1 changed files with 8 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
import _ from 'underscore';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {ipcRenderer} from 'electron';
|
import {ipcRenderer} from 'electron';
|
||||||
import {AccountStore, Actions} from 'nylas-exports';
|
import {AccountStore, Actions} from 'nylas-exports';
|
||||||
|
|
||||||
import PreferencesAccountList from './preferences-account-list';
|
import PreferencesAccountList from './preferences-account-list';
|
||||||
import PreferencesAccountDetails from './preferences-account-details';
|
import PreferencesAccountDetails from './preferences-account-details';
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ class PreferencesAccounts extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = this.getStateFromStores();
|
this.state = this.getStateFromStores();
|
||||||
this.state.selected = this.state.accounts[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -24,12 +23,16 @@ class PreferencesAccounts extends React.Component {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
getStateFromStores() {
|
getStateFromStores({selected} = {}) {
|
||||||
return {accounts: AccountStore.accounts()};
|
const accounts = AccountStore.accounts()
|
||||||
|
return {
|
||||||
|
accounts,
|
||||||
|
selected: selected ? _.findWhere(accounts, {id: selected.id}) : accounts[0],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAccountsChanged = () => {
|
_onAccountsChanged = () => {
|
||||||
this.setState(this.getStateFromStores());
|
this.setState(this.getStateFromStores(this.state));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update account list actions
|
// Update account list actions
|
||||||
|
|
Loading…
Reference in a new issue