mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 19:26:55 +08:00
fix(archive): can archive and trash from focused message
This commit is contained in:
parent
db19e88369
commit
539e9b3799
9 changed files with 72 additions and 66 deletions
|
@ -74,7 +74,6 @@ class MessageList extends React.Component
|
||||||
@_unsubscribers.push MessageStore.listen @_onChange
|
@_unsubscribers.push MessageStore.listen @_onChange
|
||||||
|
|
||||||
commands = _.extend {},
|
commands = _.extend {},
|
||||||
'core:star-item': => @_onStar()
|
|
||||||
'application:reply': => @_createReplyOrUpdateExistingDraft('reply')
|
'application:reply': => @_createReplyOrUpdateExistingDraft('reply')
|
||||||
'application:reply-all': => @_createReplyOrUpdateExistingDraft('reply-all')
|
'application:reply-all': => @_createReplyOrUpdateExistingDraft('reply-all')
|
||||||
'application:forward': => @_onForward()
|
'application:forward': => @_onForward()
|
||||||
|
@ -178,13 +177,6 @@ class MessageList extends React.Component
|
||||||
session.changes.add(updated)
|
session.changes.add(updated)
|
||||||
@_focusDraft(@_getMessageContainer(draft.clientId))
|
@_focusDraft(@_getMessageContainer(draft.clientId))
|
||||||
|
|
||||||
_onStar: =>
|
|
||||||
return unless @state.currentThread
|
|
||||||
threads = [@state.currentThread]
|
|
||||||
starred = not @state.currentThread.starred
|
|
||||||
task = new ChangeStarredTask({threads, starred})
|
|
||||||
Actions.queueTask(task)
|
|
||||||
|
|
||||||
_onForward: =>
|
_onForward: =>
|
||||||
return unless @state.currentThread
|
return unless @state.currentThread
|
||||||
Actions.composeForward(thread: @state.currentThread)
|
Actions.composeForward(thread: @state.currentThread)
|
||||||
|
|
|
@ -206,11 +206,6 @@ describe "MessageList", ->
|
||||||
MessageParticipants)
|
MessageParticipants)
|
||||||
expect(items.length).toBe 1
|
expect(items.length).toBe 1
|
||||||
|
|
||||||
it "toggles star on a thread if 'core:star-item' is fired", ->
|
|
||||||
spyOn(@messageList, "_onStar")
|
|
||||||
atom.keymaps.dispatchCommandEvent('core:star-item', document.body, new KeyboardEvent('keydown'))
|
|
||||||
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")
|
||||||
msgs = @messageList.state.messages
|
msgs = @messageList.state.messages
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DraftList extends React.Component
|
||||||
|
|
||||||
@columns = [c1, c2, c3]
|
@columns = [c1, c2, c3]
|
||||||
@commands =
|
@commands =
|
||||||
'core:remove-item': @_onDelete
|
'core:remove-from-view': @_onDelete
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
<MultiselectList
|
<MultiselectList
|
||||||
|
|
|
@ -175,12 +175,14 @@ class ThreadList extends React.Component
|
||||||
Actions.setFocus(collection: 'thread', item: item)
|
Actions.setFocus(collection: 'thread', item: item)
|
||||||
|
|
||||||
@commands =
|
@commands =
|
||||||
'core:remove-item': @_onBackspace
|
'core:remove-from-view': @_onRemoveFromView
|
||||||
|
'core:archive-item': @_onArchiveItem
|
||||||
|
'core:delete-item': @_onDeleteItem
|
||||||
'core:star-item': @_onStarItem
|
'core:star-item': @_onStarItem
|
||||||
'core:remove-and-previous': =>
|
'core:remove-and-previous': =>
|
||||||
_shift(offset: 1, afterRunning: @_onBackspace)
|
_shift(offset: 1, afterRunning: @_onRemoveFromView)
|
||||||
'core:remove-and-next': =>
|
'core:remove-and-next': =>
|
||||||
_shift(offset: -1, afterRunning: @_onBackspace)
|
_shift(offset: -1, afterRunning: @_onRemoveFromView)
|
||||||
|
|
||||||
@itemPropsProvider = (item) ->
|
@itemPropsProvider = (item) ->
|
||||||
className: classNames
|
className: classNames
|
||||||
|
@ -260,40 +262,58 @@ class ThreadList extends React.Component
|
||||||
|
|
||||||
# Additional Commands
|
# Additional Commands
|
||||||
|
|
||||||
_onStarItem: =>
|
_threadsForKeyboardAction: ->
|
||||||
return unless ThreadListStore.view()
|
return null unless ThreadListStore.view()
|
||||||
|
|
||||||
focused = FocusedContentStore.focused('thread')
|
focused = FocusedContentStore.focused('thread')
|
||||||
|
if focused
|
||||||
if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
return [focused]
|
||||||
threads = [focused]
|
|
||||||
else if ThreadListStore.view().selection.count() > 0
|
else if ThreadListStore.view().selection.count() > 0
|
||||||
threads = ThreadListStore.view().selection.items()
|
return ThreadListStore.view().selection.items()
|
||||||
else
|
else
|
||||||
threads = [focused]
|
return null
|
||||||
|
|
||||||
|
_onStarItem: =>
|
||||||
|
threads = @_threadsForKeyboardAction()
|
||||||
|
return unless threads
|
||||||
task = TaskFactory.taskForInvertingStarred({threads})
|
task = TaskFactory.taskForInvertingStarred({threads})
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
|
||||||
_onBackspace: =>
|
_onRemoveFromView: =>
|
||||||
return unless ThreadListStore.view()
|
threads = @_threadsForKeyboardAction()
|
||||||
|
if threads
|
||||||
|
if FocusedMailViewStore.mailView().canArchiveThreads()
|
||||||
|
removeMethod = TaskFactory.taskForArchiving
|
||||||
|
else if FocusedMailViewStore.mailView().canTrashThreads()
|
||||||
|
removeMethod = TaskFactory.taskForMovingToTrash
|
||||||
|
else
|
||||||
|
return
|
||||||
|
|
||||||
focused = FocusedContentStore.focused('thread')
|
task = removeMethod
|
||||||
|
threads: threads
|
||||||
if WorkspaceStore.layoutMode() is "split" and focused
|
|
||||||
task = TaskFactory.taskForMovingToTrash
|
|
||||||
threads: [focused]
|
|
||||||
fromView: FocusedMailViewStore.mailView()
|
fromView: FocusedMailViewStore.mailView()
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
|
||||||
else if ThreadListStore.view().selection.count() > 0
|
Actions.popSheet()
|
||||||
task = TaskFactory.taskForMovingToTrash
|
|
||||||
threads: ThreadListStore.view().selection.items()
|
_onArchiveItem: =>
|
||||||
|
return unless FocusedMailViewStore.mailView().canArchiveThreads()
|
||||||
|
threads = @_threadsForKeyboardAction()
|
||||||
|
if threads
|
||||||
|
task = TaskFactory.taskForArchiving
|
||||||
|
threads: threads
|
||||||
fromView: FocusedMailViewStore.mailView()
|
fromView: FocusedMailViewStore.mailView()
|
||||||
Actions.queueTask(task)
|
Actions.queueTask(task)
|
||||||
|
Actions.popSheet()
|
||||||
|
|
||||||
else if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
_onDeleteItem: =>
|
||||||
Actions.popSheet()
|
return unless FocusedMailViewStore.mailView().canTrashThreads()
|
||||||
|
threads = @_threadsForKeyboardAction()
|
||||||
|
if threads
|
||||||
|
task = TaskFactory.taskForMovingToTrash
|
||||||
|
threads: threads
|
||||||
|
fromView: FocusedMailViewStore.mailView()
|
||||||
|
Actions.queueTask(task)
|
||||||
|
Actions.popSheet()
|
||||||
|
|
||||||
|
|
||||||
module.exports = ThreadList
|
module.exports = ThreadList
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
'cmd-,' : 'application:open-preferences'
|
'cmd-,' : 'application:open-preferences'
|
||||||
'up' : 'core:previous-item'
|
'up' : 'core:previous-item'
|
||||||
'down' : 'core:next-item'
|
'down' : 'core:next-item'
|
||||||
'backspace': 'core:remove-item'
|
|
||||||
'enter' : 'core:focus-item'
|
'enter' : 'core:focus-item'
|
||||||
|
'delete': 'core:remove-from-view'
|
||||||
|
'backspace': 'core:remove-from-view'
|
||||||
|
|
||||||
# Default cross-platform core behaviors
|
# Default cross-platform core behaviors
|
||||||
'left': 'core:move-left'
|
'left': 'core:move-left'
|
||||||
|
@ -21,7 +22,6 @@
|
||||||
'shift-right': 'core:select-right'
|
'shift-right': 'core:select-right'
|
||||||
'shift-pageup': 'core:select-page-up'
|
'shift-pageup': 'core:select-page-up'
|
||||||
'shift-pagedown': 'core:select-page-down'
|
'shift-pagedown': 'core:select-page-down'
|
||||||
'delete': 'core:delete'
|
|
||||||
'shift-delete': 'core:cut'
|
'shift-delete': 'core:cut'
|
||||||
|
|
||||||
# Inputs are native by default.
|
# Inputs are native by default.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
'cmd-alt-f': 'application:focus-search'
|
'cmd-alt-f': 'application:focus-search'
|
||||||
'cmd-D': 'application:send-message'
|
'cmd-D': 'application:send-message'
|
||||||
'cmd-V': 'application:change-category'
|
'cmd-V': 'application:change-category'
|
||||||
'delete' : 'core:remove-item'
|
'cmd-e' : 'core:archive-item'
|
||||||
|
|
||||||
'body.platform-linux, body.platform-win32':
|
'body.platform-linux, body.platform-win32':
|
||||||
'ctrl-n' : 'application:new-message'
|
'ctrl-n' : 'application:new-message'
|
||||||
|
@ -19,4 +19,4 @@
|
||||||
'ctrl-alt-f': 'application:focus-search'
|
'ctrl-alt-f': 'application:focus-search'
|
||||||
'ctrl-D': 'application:send-message'
|
'ctrl-D': 'application:send-message'
|
||||||
'ctrl-shift-v': 'application:change-category'
|
'ctrl-shift-v': 'application:change-category'
|
||||||
'delete' : 'core:remove-item'
|
'ctrl-e' : 'core:archive-item'
|
||||||
|
|
|
@ -5,23 +5,22 @@
|
||||||
# darwin-gmail.cson, darwin-macmail.cson, win32-gmail.cson...
|
# darwin-gmail.cson, darwin-macmail.cson, win32-gmail.cson...
|
||||||
|
|
||||||
'body':
|
'body':
|
||||||
'c' : 'application:new-message' # Gmail
|
'c' : 'application:new-message'
|
||||||
'/' : 'application:focus-search' # Gmail
|
'/' : 'application:focus-search'
|
||||||
|
|
||||||
'r' : 'application:reply' # Gmail
|
'r' : 'application:reply'
|
||||||
'R' : 'application:reply-all' # N1
|
'a' : 'application:reply-all'
|
||||||
'a' : 'application:reply-all' # Gmail
|
'f' : 'application:forward'
|
||||||
'f' : 'application:forward' # Gmail
|
'l' : 'application:change-category'
|
||||||
'l' : 'application:change-category' # Gmail
|
'u' : 'application:pop-sheet'
|
||||||
'u' : 'application:pop-sheet' # Gmail
|
|
||||||
'delete' : 'application:pop-sheet'
|
|
||||||
|
|
||||||
'k' : 'core:previous-item' # Gmail
|
'k' : 'core:previous-item'
|
||||||
'j' : 'core:next-item' # Gmail
|
'j' : 'core:next-item'
|
||||||
']' : 'core:remove-and-previous' # Gmail
|
']' : 'core:remove-and-previous'
|
||||||
'[' : 'core:remove-and-next' # Gmail
|
'[' : 'core:remove-and-next'
|
||||||
'e' : 'core:remove-item' # Gmail
|
'#' : 'core:delete-item'
|
||||||
's' : 'core:star-item' #Gmail
|
'e' : 'core:archive-item'
|
||||||
|
's' : 'core:star-item'
|
||||||
'x' : 'core:select-item'
|
'x' : 'core:select-item'
|
||||||
|
|
||||||
# Gmail also includes some more basic ones that users expect from desktop software.
|
# Gmail also includes some more basic ones that users expect from desktop software.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
'cmd-e': 'application:focus-search'
|
'cmd-e': 'application:focus-search'
|
||||||
'cmd-f': 'application:forward'
|
'cmd-f': 'application:forward'
|
||||||
'cmd-shift-v': 'application:change-category'
|
'cmd-shift-v': 'application:change-category'
|
||||||
'cmd-d': 'core:remove-item'
|
'cmd-d': 'core:delete-item'
|
||||||
'alt-backspace':'core:undo'
|
'alt-backspace':'core:undo'
|
||||||
'alt-s': 'application:send-message'
|
'alt-s': 'application:send-message'
|
||||||
'cmd-r': 'application:reply'
|
'cmd-r': 'application:reply'
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
'ctrl-e': 'application:focus-search'
|
'ctrl-e': 'application:focus-search'
|
||||||
'ctrl-f': 'application:forward'
|
'ctrl-f': 'application:forward'
|
||||||
'ctrl-shift-v': 'application:change-category'
|
'ctrl-shift-v': 'application:change-category'
|
||||||
'ctrl-d': 'core:remove-item'
|
'ctrl-d': 'core:delete-item'
|
||||||
'alt-backspace':'core:undo'
|
'alt-backspace':'core:undo'
|
||||||
'alt-s': 'application:send-message'
|
'alt-s': 'application:send-message'
|
||||||
'ctrl-r': 'application:reply'
|
'ctrl-r': 'application:reply'
|
||||||
|
|
|
@ -8,7 +8,7 @@ CategoryStore = require '../stores/category-store'
|
||||||
|
|
||||||
class TaskFactory
|
class TaskFactory
|
||||||
|
|
||||||
taskForApplyingCategory: ({threads, fromView, category, exclusive}) ->
|
taskForApplyingCategory: ({threads, fromView, category, exclusive}) =>
|
||||||
account = AccountStore.current()
|
account = AccountStore.current()
|
||||||
if account.usesFolders()
|
if account.usesFolders()
|
||||||
return null unless category
|
return null unless category
|
||||||
|
@ -27,7 +27,7 @@ class TaskFactory
|
||||||
labelsToRemove: labelsToRemove
|
labelsToRemove: labelsToRemove
|
||||||
labelsToAdd: [category]
|
labelsToAdd: [category]
|
||||||
|
|
||||||
taskForRemovingCategory: ({threads, fromView, category, exclusive}) ->
|
taskForRemovingCategory: ({threads, fromView, category, exclusive}) =>
|
||||||
account = AccountStore.current()
|
account = AccountStore.current()
|
||||||
if account.usesFolders()
|
if account.usesFolders()
|
||||||
return new ChangeFolderTask
|
return new ChangeFolderTask
|
||||||
|
@ -45,27 +45,27 @@ class TaskFactory
|
||||||
labelsToRemove: [category]
|
labelsToRemove: [category]
|
||||||
labelsToAdd: labelsToAdd
|
labelsToAdd: labelsToAdd
|
||||||
|
|
||||||
taskForArchiving: ({threads, fromView}) ->
|
taskForArchiving: ({threads, fromView}) =>
|
||||||
category = CategoryStore.getArchiveCategory()
|
category = CategoryStore.getArchiveCategory()
|
||||||
@taskForApplyingCategory({threads, fromView, category, exclusive: true})
|
@taskForApplyingCategory({threads, fromView, category, exclusive: true})
|
||||||
|
|
||||||
taskForUnarchiving: ({threads, fromView}) ->
|
taskForUnarchiving: ({threads, fromView}) =>
|
||||||
category = CategoryStore.getArchiveCategory()
|
category = CategoryStore.getArchiveCategory()
|
||||||
@taskForRemovingCategory({threads, fromView, category, exclusive: true})
|
@taskForRemovingCategory({threads, fromView, category, exclusive: true})
|
||||||
|
|
||||||
taskForMovingToTrash: ({threads, fromView}) ->
|
taskForMovingToTrash: ({threads, fromView}) =>
|
||||||
category = CategoryStore.getTrashCategory()
|
category = CategoryStore.getTrashCategory()
|
||||||
@taskForApplyingCategory({threads, fromView, category, exclusive: true})
|
@taskForApplyingCategory({threads, fromView, category, exclusive: true})
|
||||||
|
|
||||||
taskForMovingFromTrash: ({threads, fromView}) ->
|
taskForMovingFromTrash: ({threads, fromView}) =>
|
||||||
category = CategoryStore.getTrashCategory()
|
category = CategoryStore.getTrashCategory()
|
||||||
@taskForRemovingCategory({threads, fromView, category, exclusive: true})
|
@taskForRemovingCategory({threads, fromView, category, exclusive: true})
|
||||||
|
|
||||||
taskForInvertingUnread: ({threads}) ->
|
taskForInvertingUnread: ({threads}) =>
|
||||||
unread = _.every threads, (t) -> _.isMatch(t, {unread: false})
|
unread = _.every threads, (t) -> _.isMatch(t, {unread: false})
|
||||||
return new ChangeUnreadTask({threads, unread})
|
return new ChangeUnreadTask({threads, unread})
|
||||||
|
|
||||||
taskForInvertingStarred: ({threads}) ->
|
taskForInvertingStarred: ({threads}) =>
|
||||||
starred = _.every threads, (t) -> _.isMatch(t, {starred: false})
|
starred = _.every threads, (t) -> _.isMatch(t, {starred: false})
|
||||||
return new ChangeStarredTask({threads, starred})
|
return new ChangeStarredTask({threads, starred})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue