fix(shortcuts): Add shortcut to mark as spam, fixes #765

- Minor cleanup + docs
This commit is contained in:
Juan Tejada 2016-02-01 12:19:18 -08:00
parent 3d3f7fa315
commit 4861c3e2ab
4 changed files with 18 additions and 3 deletions

View file

@ -58,6 +58,7 @@ class ThreadList extends React.Component
'application:mark-unimportant': => @_onSetImportant(false)
'application:mark-as-unread': => @_onSetUnread(true)
'application:mark-as-read': => @_onSetUnread(false)
'application:report-as-spam': => @_onMarkAsSpam(false)
'application:remove-and-previous': =>
@_shift(offset: -1, afterRunning: @_onRemoveFromView)
'application:remove-and-next': =>
@ -176,6 +177,14 @@ class ThreadList extends React.Component
Actions.queueTask(task)
Actions.popSheet()
_onMarkAsSpam: =>
threads = @_threadsForKeyboardAction()
return unless threads
tasks = TaskFactory.tasksForMarkingAsSpam(
threads: threads
)
Actions.queueTasks(tasks)
_onRemoveFromView: =>
threads = @_threadsForKeyboardAction()
backspaceDelete = NylasEnv.config.get('core.reading.backspaceDelete')

View file

@ -74,6 +74,8 @@ class CategoryStore extends NylasStore
return _.findWhere(@_standardCategories[asAccountId(accountOrId)], {name})
# Public: Returns the set of all standard categories that match the given
# names for each of the provided accounts
getStandardCategories: (accountsOrIds, names...) ->
if Array.isArray(accountsOrIds)
res = []

View file

@ -71,6 +71,13 @@ class TaskFactory
labelsToRemove: [category]
labelsToAdd: labelsToAdd
tasksForMarkingAsSpam: ({threads}) =>
@tasksForApplyingCategories
threads: threads,
categoriesToRemove: (accountId) ->
[CategoryStore.getStandardCategory(accountId, 'inbox')]
categoryToAdd: (accountId) -> CategoryStore.getStandardCategory(accountId, 'spam')
tasksForArchiving: ({threads, fromPerspective}) =>
@tasksForApplyingCategories
threads: threads,

View file

@ -43,9 +43,6 @@ class MailboxPerspective
@forInbox: (accountsOrIds) =>
@forStandardCategories(accountsOrIds, 'inbox')
@forAll: (accountsOrIds) =>
@forStandardCategories(accountsOrIds, 'all')
# Instance Methods