mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-14 16:44:36 +08:00
fix(T2049): in 2-pane mode, keyboard actions are applied to selection, not message you are viewing
Fixes T2049 and moves ownership of the reply/reply-all/forward actions to the MessageList, which Rob did for starring and actually makes more sense.
This commit is contained in:
parent
f043d0e506
commit
e614bea92e
4 changed files with 37 additions and 38 deletions
|
@ -66,7 +66,10 @@ class MessageList extends React.Component
|
||||||
@_unsubscribers.push MessageStore.listen @_onChange
|
@_unsubscribers.push MessageStore.listen @_onChange
|
||||||
|
|
||||||
commands = _.extend {},
|
commands = _.extend {},
|
||||||
'core:star-item': => @_onStarItem()
|
'core:star-item': => @_onStar()
|
||||||
|
'application:reply': => @_onReply()
|
||||||
|
'application:reply-all': => @_onReplyAll()
|
||||||
|
'application:forward': => @_onForward()
|
||||||
|
|
||||||
@command_unsubscriber = atom.commands.add('body', commands)
|
@command_unsubscriber = atom.commands.add('body', commands)
|
||||||
|
|
||||||
|
@ -113,13 +116,26 @@ class MessageList extends React.Component
|
||||||
_focusDraft: (draftElement) =>
|
_focusDraft: (draftElement) =>
|
||||||
draftElement.focus()
|
draftElement.focus()
|
||||||
|
|
||||||
_onStarItem: =>
|
_onStar: =>
|
||||||
|
return unless @state.currentThread
|
||||||
if @state.currentThread.isStarred()
|
if @state.currentThread.isStarred()
|
||||||
task = new AddRemoveTagsTask(@state.currentThread, [], ['starred'])
|
task = new AddRemoveTagsTask(@state.currentThread, [], ['starred'])
|
||||||
else
|
else
|
||||||
task = new AddRemoveTagsTask(@state.currentThread, ['starred'], [])
|
task = new AddRemoveTagsTask(@state.currentThread, ['starred'], [])
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
|
||||||
|
_onReply: =>
|
||||||
|
return unless @state.currentThread
|
||||||
|
Actions.composeReply(thread: @state.currentThread)
|
||||||
|
|
||||||
|
_onReplyAll: =>
|
||||||
|
return unless @state.currentThread
|
||||||
|
Actions.composeReplyAll(thread: @state.currentThread)
|
||||||
|
|
||||||
|
_onForward: =>
|
||||||
|
return unless @state.currentThread
|
||||||
|
Actions.composeForward(thread: @state.currentThread)
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
if not @state.currentThread?
|
if not @state.currentThread?
|
||||||
return <div className="message-list" id="message-list"></div>
|
return <div className="message-list" id="message-list"></div>
|
||||||
|
|
|
@ -217,9 +217,9 @@ describe "MessageList", ->
|
||||||
expect(items.length).toBe 1
|
expect(items.length).toBe 1
|
||||||
|
|
||||||
it "toggles star on a thread if 's' is pressed", ->
|
it "toggles star on a thread if 's' is pressed", ->
|
||||||
spyOn(@messageList, "_onStarItem")
|
spyOn(@messageList, "_onStar")
|
||||||
NylasTestUtils.keyPress("s", document.body)
|
NylasTestUtils.keyPress("s", document.body)
|
||||||
expect(@messageList._onStarItem).toHaveBeenCalled()
|
expect(@messageList._onStar).toHaveBeenCalled()
|
||||||
|
|
||||||
it "focuses new composers when a draft is added", ->
|
it "focuses new composers when a draft is added", ->
|
||||||
spyOn(@messageList, "_focusDraft")
|
spyOn(@messageList, "_focusDraft")
|
||||||
|
|
|
@ -125,11 +125,13 @@ ThreadListStore = Reflux.createStore
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
|
||||||
_onToggleStarFocused: ->
|
_onToggleStarFocused: ->
|
||||||
focusedThread = FocusedContentStore.focused('thread')
|
focused = FocusedContentStore.focused('thread')
|
||||||
if focusedThread.isStarred()
|
return unless focused
|
||||||
task = new AddRemoveTagsTask(focusedThread, [], ['starred'])
|
|
||||||
|
if focused.isStarred()
|
||||||
|
task = new AddRemoveTagsTask(focused, [], ['starred'])
|
||||||
else
|
else
|
||||||
task = new AddRemoveTagsTask(focusedThread, ['starred'], [])
|
task = new AddRemoveTagsTask(focused, ['starred'], [])
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
|
||||||
_onArchive: ->
|
_onArchive: ->
|
||||||
|
|
|
@ -133,9 +133,6 @@ class ThreadList extends React.Component
|
||||||
'core:star-item': @_onStarItem
|
'core:star-item': @_onStarItem
|
||||||
'core:remove-and-previous': -> Actions.archiveAndPrevious()
|
'core:remove-and-previous': -> Actions.archiveAndPrevious()
|
||||||
'core:remove-and-next': -> Actions.archiveAndNext()
|
'core:remove-and-next': -> Actions.archiveAndNext()
|
||||||
'application:reply': @_onReply
|
|
||||||
'application:reply-all': @_onReplyAll
|
|
||||||
'application:forward': @_onForward
|
|
||||||
|
|
||||||
@itemPropsProvider = (item) ->
|
@itemPropsProvider = (item) ->
|
||||||
className: classNames
|
className: classNames
|
||||||
|
@ -148,12 +145,6 @@ class ThreadList extends React.Component
|
||||||
componentWillUnmount: =>
|
componentWillUnmount: =>
|
||||||
window.removeEventListener('resize', @_onResize)
|
window.removeEventListener('resize', @_onResize)
|
||||||
|
|
||||||
_onStarItem: =>
|
|
||||||
if @state.style is 'wide' or ThreadListStore.view().selection.count() > 0
|
|
||||||
Actions.toggleStarSelection()
|
|
||||||
else
|
|
||||||
Actions.toggleStarFocused()
|
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
if @state.style is 'wide'
|
if @state.style is 'wide'
|
||||||
<MultiselectList
|
<MultiselectList
|
||||||
|
@ -188,31 +179,21 @@ class ThreadList extends React.Component
|
||||||
|
|
||||||
# Additional Commands
|
# Additional Commands
|
||||||
|
|
||||||
|
_onStarItem: =>
|
||||||
|
if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
||||||
|
Actions.toggleStarFocused()
|
||||||
|
else if ThreadListStore.view().selection.count() > 0
|
||||||
|
Actions.toggleStarSelection()
|
||||||
|
else
|
||||||
|
Actions.toggleStarFocused()
|
||||||
|
|
||||||
_onArchive: =>
|
_onArchive: =>
|
||||||
if ThreadListStore.view().selection.count() is 0
|
if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
||||||
Actions.archive()
|
Actions.archive()
|
||||||
else
|
else if ThreadListStore.view().selection.count() > 0
|
||||||
Actions.archiveSelection()
|
Actions.archiveSelection()
|
||||||
|
|
||||||
_onReply: ({focusedId}) =>
|
|
||||||
return unless focusedId? and @_viewingFocusedThread()
|
|
||||||
Actions.composeReply(threadId: focusedId)
|
|
||||||
|
|
||||||
_onReplyAll: ({focusedId}) =>
|
|
||||||
return unless focusedId? and @_viewingFocusedThread()
|
|
||||||
Actions.composeReplyAll(threadId: focusedId)
|
|
||||||
|
|
||||||
_onForward: ({focusedId}) =>
|
|
||||||
return unless focusedId? and @_viewingFocusedThread()
|
|
||||||
Actions.composeForward(threadId: focusedId)
|
|
||||||
|
|
||||||
# Helpers
|
|
||||||
|
|
||||||
_viewingFocusedThread: =>
|
|
||||||
if WorkspaceStore.layoutMode() is "list"
|
|
||||||
WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
|
||||||
else
|
else
|
||||||
true
|
Actions.archive()
|
||||||
|
|
||||||
|
|
||||||
module.exports = ThreadList
|
module.exports = ThreadList
|
||||||
|
|
Loading…
Add table
Reference in a new issue