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