From 4861c3e2ab5257380f67cc7865037cb7b34023ca Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Mon, 1 Feb 2016 12:19:18 -0800 Subject: [PATCH] fix(shortcuts): Add shortcut to mark as spam, fixes #765 - Minor cleanup + docs --- internal_packages/thread-list/lib/thread-list.cjsx | 9 +++++++++ src/flux/stores/category-store.coffee | 2 ++ src/flux/tasks/task-factory.coffee | 7 +++++++ src/mailbox-perspective.coffee | 3 --- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal_packages/thread-list/lib/thread-list.cjsx b/internal_packages/thread-list/lib/thread-list.cjsx index 6862ceacd..b54b76e2e 100644 --- a/internal_packages/thread-list/lib/thread-list.cjsx +++ b/internal_packages/thread-list/lib/thread-list.cjsx @@ -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') diff --git a/src/flux/stores/category-store.coffee b/src/flux/stores/category-store.coffee index 23b78a487..1e4b54e9d 100644 --- a/src/flux/stores/category-store.coffee +++ b/src/flux/stores/category-store.coffee @@ -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 = [] diff --git a/src/flux/tasks/task-factory.coffee b/src/flux/tasks/task-factory.coffee index 90c57732f..ae7a82ddc 100644 --- a/src/flux/tasks/task-factory.coffee +++ b/src/flux/tasks/task-factory.coffee @@ -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, diff --git a/src/mailbox-perspective.coffee b/src/mailbox-perspective.coffee index 2022c762a..dbaff39c6 100644 --- a/src/mailbox-perspective.coffee +++ b/src/mailbox-perspective.coffee @@ -43,9 +43,6 @@ class MailboxPerspective @forInbox: (accountsOrIds) => @forStandardCategories(accountsOrIds, 'inbox') - @forAll: (accountsOrIds) => - @forStandardCategories(accountsOrIds, 'all') - # Instance Methods