mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-02 02:53:01 +08:00
refactor(focus): Move code for focusing threads to FocusedContentStore
This commit is contained in:
parent
a4a41cf6a2
commit
26787b77d3
3 changed files with 18 additions and 13 deletions
|
@ -58,17 +58,11 @@ export class Notifier {
|
|||
NylasEnv.displayWindow()
|
||||
}
|
||||
|
||||
const currentCategories = FocusedPerspectiveStore.current().categories();
|
||||
const desiredCategory = thread.categoryNamed('inbox');
|
||||
|
||||
if (!desiredCategory) {
|
||||
return;
|
||||
}
|
||||
if (!_.pluck(currentCategories, 'id').includes(desiredCategory.id)) {
|
||||
const filter = MailboxPerspective.forCategory(desiredCategory);
|
||||
Actions.focusMailboxPerspective(filter);
|
||||
}
|
||||
Actions.setFocus({collection: 'thread', item: thread});
|
||||
Actions.setFocus({
|
||||
collection: 'thread',
|
||||
item: thread,
|
||||
desiredCategoryName: 'inbox',
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ Reflux = require 'reflux'
|
|||
AccountStore = require './account-store'
|
||||
WorkspaceStore = require './workspace-store'
|
||||
DatabaseStore = require './database-store'
|
||||
FocusedPerspectiveStore = require './focused-perspective-store'
|
||||
MailboxPerspective = require '../../mailbox-perspective'
|
||||
Actions = require '../actions'
|
||||
Thread = require('../models/thread').default
|
||||
Model = require '../models/model'
|
||||
|
@ -90,11 +92,20 @@ class FocusedContentStore
|
|||
@_keyboardCursor[collection] = item
|
||||
@triggerAfterAnimationFrame({ impactsCollection: (c) -> c is collection })
|
||||
|
||||
_onFocus: ({collection, item, usingClick}) =>
|
||||
_onFocus: ({collection, item, usingClick, desiredCategoryName}) =>
|
||||
throw new Error("focus() requires a Model or null") if item and not (item instanceof Model)
|
||||
throw new Error("focus() requires a collection") unless collection
|
||||
return if @_focused[collection]?.id is item?.id
|
||||
|
||||
if desiredCategoryName
|
||||
currentCategories = FocusedPerspectiveStore.current().categories()
|
||||
desiredCategory = item.categoryNamed(desiredCategoryName)
|
||||
|
||||
if desiredCategory
|
||||
unless desiredCategory.id in _.pluck(currentCategories, 'id')
|
||||
filter = MailboxPerspective.forCategory(desiredCategory)
|
||||
Actions.focusMailboxPerspective(filter)
|
||||
|
||||
@_focused[collection] = item
|
||||
@_focusedUsingClick[collection] = usingClick
|
||||
@_keyboardCursor[collection] = item if item
|
||||
|
|
2
src/pro
2
src/pro
|
@ -1 +1 @@
|
|||
Subproject commit 8a3b33001749f74933bff9d800080279935cb768
|
||||
Subproject commit 5abcef20c3738e710ad3a61f36efe83e905ff8d0
|
Loading…
Reference in a new issue