diff --git a/src/flux/stores/account-store.coffee b/src/flux/stores/account-store.coffee index e0f8e6429..85b527f06 100644 --- a/src/flux/stores/account-store.coffee +++ b/src/flux/stores/account-store.coffee @@ -218,6 +218,9 @@ class AccountStore extends NylasStore accounts: => @_accounts + accountIds: => + _.pluck(@_accounts, 'id') + accountsForItems: (items) => accounts = {} items.forEach ({accountId}) => diff --git a/src/flux/stores/focused-perspective-store.coffee b/src/flux/stores/focused-perspective-store.coffee index 5be1e93e0..58d60b93d 100644 --- a/src/flux/stores/focused-perspective-store.coffee +++ b/src/flux/stores/focused-perspective-store.coffee @@ -116,7 +116,10 @@ class FocusedPerspectiveStore extends NylasStore @_current sidebarAccountIds: => - NylasEnv.savedState.sidebarAccountIds ?= AccountStore.accounts().map((acc) => acc.id) + NylasEnv.savedState.sidebarAccountIds ?= AccountStore.accountIds() + accIdsAreInvalid = not NylasEnv.savedState.sidebarAccountIds.every((accId) => AccountStore.accountForId(accId)?) + if accIdsAreInvalid + NylasEnv.savedState.sidebarAccountIds = AccountStore.accountIds() return NylasEnv.savedState.sidebarAccountIds module.exports = new FocusedPerspectiveStore()