From 4c00cccbee14b00690f04d596d188f88058f9c0c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 4 May 2016 09:25:13 -0700 Subject: [PATCH] fix(perspective): Always pop to root sheet when changing #2125 --- src/flux/actions.coffee | 7 +++++++ src/flux/stores/focused-perspective-store.coffee | 11 ++++++----- src/flux/stores/workspace-store.coffee | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/flux/actions.coffee b/src/flux/actions.coffee index 0d5ea0541..46fc36039 100644 --- a/src/flux/actions.coffee +++ b/src/flux/actions.coffee @@ -479,6 +479,13 @@ class Actions ### @popSheet: ActionScopeWindow + ### + Public: Pop the to the root sheet currently selected. + + *Scope: Window* + ### + @popToRootSheet: ActionScopeWindow + ### Public: Push a sheet of a specific type onto the Sheet stack maintained by the {WorkspaceStore}. Note that sheets have no state. To show a *specific* thread, diff --git a/src/flux/stores/focused-perspective-store.coffee b/src/flux/stores/focused-perspective-store.coffee index 26371a919..506a07b7c 100644 --- a/src/flux/stores/focused-perspective-store.coffee +++ b/src/flux/stores/focused-perspective-store.coffee @@ -60,7 +60,6 @@ class FocusedPerspectiveStore extends NylasStore @_setPerspective(@_defaultPerspective(accountIds)) _onFocusPerspective: (perspective) => - return if perspective.isEqual(@_current) @_setPerspective(perspective) _onFocusAccounts: (accountsOrIds) => @@ -72,18 +71,20 @@ class FocusedPerspectiveStore extends NylasStore return MailboxPerspective.forInbox(accounts) _setPerspective: (perspective) -> - return if perspective?.isEqual(@_current) - NylasEnv.savedState.perspective = perspective.toJSON() - @_current = perspective - @trigger() + unless perspective.isEqual(@_current) + NylasEnv.savedState.perspective = perspective.toJSON() + @_current = perspective + @trigger() if perspective.drafts desired = WorkspaceStore.Sheet.Drafts else desired = WorkspaceStore.Sheet.Threads + # Always switch to the correct sheet and pop to root when perspective set if desired and WorkspaceStore.rootSheet() isnt desired Actions.selectRootSheet(desired) + Actions.popToRootSheet() _setPerspectiveByName: (categoryName) -> categories = @_current.accountIds.map (aid) -> diff --git a/src/flux/stores/workspace-store.coffee b/src/flux/stores/workspace-store.coffee index b198379fa..790593e7b 100644 --- a/src/flux/stores/workspace-store.coffee +++ b/src/flux/stores/workspace-store.coffee @@ -25,8 +25,8 @@ class WorkspaceStore extends NylasStore @listenTo Actions.setFocus, @_onSetFocus @listenTo Actions.toggleWorkspaceLocationHidden, @_onToggleLocationHidden @listenTo Actions.popSheet, @popSheet + @listenTo Actions.popToRootSheet, @popToRootSheet @listenTo Actions.pushSheet, @pushSheet - @listenTo Actions.focusMailboxPerspective, @popToRootSheet {windowType} = NylasEnv.getLoadSettings() unless windowType is 'onboarding'