fix(send+archive): Update to use focused perspective

This commit is contained in:
Ben Gotow 2016-01-29 19:01:47 -08:00
parent fde868a62e
commit 685fa625a5
2 changed files with 12 additions and 5 deletions

View file

@ -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

View file

@ -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) ? []