From 8f6dff7da82b70b93086e59a242eca9e4a0eed57 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 16 Feb 2016 11:41:15 -0800 Subject: [PATCH] fix(important): Remove todo, reference to usesImportantFlag. Fixes #1331 --- .../thread-list/lib/thread-list.cjsx | 33 ++++++++++--------- src/flux/tasks/task-factory.coffee | 3 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/internal_packages/thread-list/lib/thread-list.cjsx b/internal_packages/thread-list/lib/thread-list.cjsx index 5050a6cee..4e76f83fc 100644 --- a/internal_packages/thread-list/lib/thread-list.cjsx +++ b/internal_packages/thread-list/lib/thread-list.cjsx @@ -153,20 +153,25 @@ class ThreadList extends React.Component _onSetImportant: (important) => threads = @_threadsForKeyboardAction() return unless threads - - # TODO Can not apply to threads across more than one account for now - account = AccountStore.accountForItems(threads) - return unless account? - - return unless account.usesImportantFlag() return unless NylasEnv.config.get('core.workspace.showImportant') - category = CategoryStore.getStandardCategory(account, 'important') - if important - task = TaskFactory.taskForApplyingCategory({threads, category}) - else - task = TaskFactory.taskForRemovingCategory({threads, category}) - Actions.queueTask(task) + if important + tasks = TaskFactory.tasksForApplyingCategories + threads: threads + categoriesToRemove: (accountId) -> [] + categoryToAdd: (accountId) -> + CategoryStore.getStandardCategory(accountId, 'important') + + else + tasks = TaskFactory.tasksForApplyingCategories + threads: threads + categoriesToRemove: (accountId) -> + important = CategoryStore.getStandardCategory(accountId, 'important') + return [important] if important + return [] + categoryToAdd: (accountId) -> null + + Actions.queueTasks(tasks) _onSetUnread: (unread) => threads = @_threadsForKeyboardAction() @@ -180,9 +185,7 @@ class ThreadList extends React.Component _onMarkAsSpam: => threads = @_threadsForKeyboardAction() return unless threads - tasks = TaskFactory.tasksForMarkingAsSpam( - threads: threads - ) + tasks = TaskFactory.tasksForMarkingAsSpam({threads}) Actions.queueTasks(tasks) _onRemoveFromView: => diff --git a/src/flux/tasks/task-factory.coffee b/src/flux/tasks/task-factory.coffee index 261e459fb..46659be33 100644 --- a/src/flux/tasks/task-factory.coffee +++ b/src/flux/tasks/task-factory.coffee @@ -89,7 +89,8 @@ class TaskFactory threads: threads, categoriesToRemove: (accountId) -> [CategoryStore.getStandardCategory(accountId, 'inbox')] - categoryToAdd: (accountId) -> CategoryStore.getStandardCategory(accountId, 'spam') + categoryToAdd: (accountId) -> + CategoryStore.getStandardCategory(accountId, 'spam') tasksForArchiving: ({threads, fromPerspective}) => @tasksForApplyingCategories