mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-08 13:44:53 +08:00
fix(perspective): Just wait for first CategoryStore trigger to load perspective
The FocusedPerspectiveStore wants to restore a saved current perspective from disk. It needs to wait for the categories to be ready, but it doesn't necessarily need to wait for them to be synced, because it's unlikely unsynced categories are in the saved perspective and it just falls back to unified inbox. I think there was some dead code in `_onCategoryStoreChanged` that initialized the perspective also, so I merged the two
This commit is contained in:
parent
df44eb493d
commit
99bd3c1e69
1 changed files with 6 additions and 8 deletions
|
@ -9,15 +9,12 @@ class FocusedPerspectiveStore extends NylasStore
|
|||
constructor: ->
|
||||
@_current = MailboxPerspective.forNothing()
|
||||
|
||||
CategoryStore.whenCategoriesReady().then =>
|
||||
@listenTo CategoryStore, @_onCategoryStoreChanged
|
||||
@listenTo Actions.focusMailboxPerspective, @_onFocusPerspective
|
||||
@listenTo Actions.focusDefaultMailboxPerspectiveForAccounts, @_onFocusAccounts
|
||||
@listenTo CategoryStore, @_onCategoryStoreChanged
|
||||
@listenTo Actions.focusMailboxPerspective, @_onFocusPerspective
|
||||
@listenTo Actions.focusDefaultMailboxPerspectiveForAccounts, @_onFocusAccounts
|
||||
|
||||
perspective = @_initCurrentPerspective(NylasEnv.savedState.perspective)
|
||||
@_setPerspective(perspective)
|
||||
|
||||
_initCurrentPerspective: (savedPerspective, accounts = AccountStore.accounts()) =>
|
||||
_createDefaultPerspective: (savedPerspective, accounts = AccountStore.accounts()) =>
|
||||
if savedPerspective
|
||||
perspective = MailboxPerspective.fromJSON(savedPerspective)
|
||||
if perspective
|
||||
|
@ -32,7 +29,8 @@ class FocusedPerspectiveStore extends NylasStore
|
|||
|
||||
_onCategoryStoreChanged: ->
|
||||
if @_current.isEqual(MailboxPerspective.forNothing())
|
||||
@_setPerspective(@_defaultPerspective())
|
||||
perspective = @_createDefaultPerspective(NylasEnv.savedState.perspective)
|
||||
@_setPerspective(perspective)
|
||||
else
|
||||
accountIds = @_current.accountIds
|
||||
categories = @_current.categories()
|
||||
|
|
Loading…
Add table
Reference in a new issue