fix(sidebar): Make sure saved sidebar accts are correct

- Sidebar accounts may become invalid when switching from staging to
prod
This commit is contained in:
Juan Tejada 2016-06-16 16:40:47 -07:00
parent e87096d7a3
commit 54a74e317d
2 changed files with 7 additions and 1 deletions

View file

@ -218,6 +218,9 @@ class AccountStore extends NylasStore
accounts: =>
@_accounts
accountIds: =>
_.pluck(@_accounts, 'id')
accountsForItems: (items) =>
accounts = {}
items.forEach ({accountId}) =>

View file

@ -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()