mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 00:25:03 +08:00
fix(sidebar): Correctly show all accounts in sidebar during initial sync
Ref #1587
This commit is contained in:
parent
69aaf27709
commit
5c7518e958
2 changed files with 12 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
_ = require 'underscore'
|
||||
{Actions, AccountStore, MenuHelpers} = require 'nylas-exports'
|
||||
{Actions, MenuHelpers} = require 'nylas-exports'
|
||||
|
||||
|
||||
class AccountCommands
|
||||
|
|
|
@ -12,6 +12,7 @@ class FocusedPerspectiveStore extends NylasStore {
|
|||
constructor() {
|
||||
super()
|
||||
this._current = MailboxPerspective.forNothing();
|
||||
this._initialized = false
|
||||
|
||||
this.listenTo(CategoryStore, this._onCategoryStoreChanged);
|
||||
this.listenTo(Actions.focusMailboxPerspective, this._onFocusPerspective);
|
||||
|
@ -80,14 +81,17 @@ class FocusedPerspectiveStore extends NylasStore {
|
|||
if (json) {
|
||||
perspective = MailboxPerspective.fromJSON(json);
|
||||
}
|
||||
this._initialized = true
|
||||
|
||||
if (!perspective || !this._isValidPerspective(perspective)) {
|
||||
perspective = this._defaultPerspective();
|
||||
sidebarAccountIds = perspective.accountIds;
|
||||
this._initialized = false
|
||||
}
|
||||
|
||||
if (!sidebarAccountIds || !this._isValidAccountSet(sidebarAccountIds) || sidebarAccountIds.length < perspective.accountIds.length) {
|
||||
sidebarAccountIds = perspective.accountIds;
|
||||
this._initialized = false
|
||||
}
|
||||
|
||||
this._setPerspective(perspective, sidebarAccountIds);
|
||||
|
@ -95,7 +99,7 @@ class FocusedPerspectiveStore extends NylasStore {
|
|||
|
||||
// Inbound Events
|
||||
_onCategoryStoreChanged = () => {
|
||||
if (this._current.isEqual(MailboxPerspective.forNothing())) {
|
||||
if (!this._initialized) {
|
||||
this._initializeFromSavedState();
|
||||
} else if (!this._isValidPerspective(this._current)) {
|
||||
this._setPerspective(this._defaultPerspective(this._current.accountIds));
|
||||
|
@ -153,7 +157,12 @@ class FocusedPerspectiveStore extends NylasStore {
|
|||
shouldTrigger = true;
|
||||
}
|
||||
|
||||
if (sidebarAccountIds && !_.isEqual(NylasEnv.savedState.sidebarAccountIds, sidebarAccountIds)) {
|
||||
const shouldSaveSidebarAccountIds = (
|
||||
sidebarAccountIds &&
|
||||
!_.isEqual(NylasEnv.savedState.sidebarAccountIds, sidebarAccountIds) &&
|
||||
this._initialized === true
|
||||
)
|
||||
if (shouldSaveSidebarAccountIds) {
|
||||
NylasEnv.savedState.sidebarAccountIds = sidebarAccountIds;
|
||||
shouldTrigger = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue