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, {React,
Actions, Actions,
Thread,
DatabaseStore,
TaskFactory, TaskFactory,
ComposerExtension, ComposerExtension,
FocusedMailViewStore} = require 'nylas-exports' FocusedPerspectiveStore} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit' {RetinaImg} = require 'nylas-component-kit'
@ -18,9 +20,10 @@ class SendAndArchiveExtension extends ComposerExtension
@_sendAndArchive: ({draft}) -> @_sendAndArchive: ({draft}) ->
Actions.sendDraft(draft.clientId) Actions.sendDraft(draft.clientId)
archiveTask = TaskFactory.taskForArchiving DatabaseStore.modelify(Thread, [draft.threadId]).then (threads) =>
threads: [draft.threadId] tasks = TaskFactory.tasksForArchiving
fromView: FocusedMailViewStore.mailView() threads: threads
Actions.queueTask(archiveTask) fromPerspective: FocusedPerspectiveStore.current()
Actions.queueTasks(tasks)
module.exports = SendAndArchiveExtension module.exports = SendAndArchiveExtension

View file

@ -5,6 +5,7 @@ ChangeUnreadTask = require './change-unread-task'
ChangeStarredTask = require './change-starred-task' ChangeStarredTask = require './change-starred-task'
AccountStore = require '../stores/account-store' AccountStore = require '../stores/account-store'
CategoryStore = require '../stores/category-store' CategoryStore = require '../stores/category-store'
Thread = require '../models/thread'
class TaskFactory class TaskFactory
@ -13,6 +14,9 @@ class TaskFactory
tasks = [] tasks = []
for thread in threads for thread in threads
unless thread instanceof Thread
throw new Error("tasksForApplyingCategories: `threads` must be instances of Thread")
accountId = thread.accountId accountId = thread.accountId
byAccount[accountId] ?= byAccount[accountId] ?=
categoriesToRemove: categoriesToRemove?(accountId) ? [] categoriesToRemove: categoriesToRemove?(accountId) ? []