From 685fa625a5094ede22e7ce6cce5ce4b65b2d676c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 29 Jan 2016 19:01:47 -0800 Subject: [PATCH] fix(send+archive): Update to use focused perspective --- .../lib/send-and-archive-extension.cjsx | 13 ++++++++----- src/flux/tasks/task-factory.coffee | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/internal_packages/send-and-archive/lib/send-and-archive-extension.cjsx b/internal_packages/send-and-archive/lib/send-and-archive-extension.cjsx index 6911aaf08..f15368fea 100644 --- a/internal_packages/send-and-archive/lib/send-and-archive-extension.cjsx +++ b/internal_packages/send-and-archive/lib/send-and-archive-extension.cjsx @@ -1,8 +1,10 @@ {React, Actions, + Thread, + DatabaseStore, TaskFactory, ComposerExtension, - FocusedMailViewStore} = require 'nylas-exports' + FocusedPerspectiveStore} = require 'nylas-exports' {RetinaImg} = require 'nylas-component-kit' @@ -18,9 +20,10 @@ class SendAndArchiveExtension extends ComposerExtension @_sendAndArchive: ({draft}) -> Actions.sendDraft(draft.clientId) - archiveTask = TaskFactory.taskForArchiving - threads: [draft.threadId] - fromView: FocusedMailViewStore.mailView() - Actions.queueTask(archiveTask) + DatabaseStore.modelify(Thread, [draft.threadId]).then (threads) => + tasks = TaskFactory.tasksForArchiving + threads: threads + fromPerspective: FocusedPerspectiveStore.current() + Actions.queueTasks(tasks) module.exports = SendAndArchiveExtension diff --git a/src/flux/tasks/task-factory.coffee b/src/flux/tasks/task-factory.coffee index b69a2a8ea..90c57732f 100644 --- a/src/flux/tasks/task-factory.coffee +++ b/src/flux/tasks/task-factory.coffee @@ -5,6 +5,7 @@ ChangeUnreadTask = require './change-unread-task' ChangeStarredTask = require './change-starred-task' AccountStore = require '../stores/account-store' CategoryStore = require '../stores/category-store' +Thread = require '../models/thread' class TaskFactory @@ -13,6 +14,9 @@ class TaskFactory tasks = [] for thread in threads + unless thread instanceof Thread + throw new Error("tasksForApplyingCategories: `threads` must be instances of Thread") + accountId = thread.accountId byAccount[accountId] ?= categoriesToRemove: categoriesToRemove?(accountId) ? []