From 23c68df4c09bf51730902b397e25175151cfab0f Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Thu, 10 Mar 2016 15:41:42 -0800 Subject: [PATCH] fix(sent): Do not allow sent or drafts to be modified - Specifically, when dragging from the sent perspective, we should not allow the sent label to be removed. - If moved to trash or spam, `all mail` will be correctly removed from the thread, but it will keep sent label - Show sent MailLabel on the threads --- spec/models/category-spec.coffee | 2 +- spec/models/thread-spec.coffee | 4 ++-- src/flux/models/category.coffee | 2 +- src/mailbox-perspective.coffee | 7 +++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/models/category-spec.coffee b/spec/models/category-spec.coffee index 19db7ae53..2a64e51c8 100644 --- a/spec/models/category-spec.coffee +++ b/spec/models/category-spec.coffee @@ -58,5 +58,5 @@ describe 'Category', -> cat.name = 'sent' expect(cat.isUserCategory()).toBe false expect(cat.isStandardCategory()).toBe true - expect(cat.isHiddenCategory()).toBe true + expect(cat.isHiddenCategory()).toBe false expect(cat.isLockedCategory()).toBe true diff --git a/spec/models/thread-spec.coffee b/spec/models/thread-spec.coffee index e5b6f8d64..9be67a467 100644 --- a/spec/models/thread-spec.coffee +++ b/spec/models/thread-spec.coffee @@ -70,8 +70,8 @@ describe 'Thread', -> expect(actualOut.length).toBe 1 expect(actualOut[0].displayName).toBe 'not important' - it "doesn't display 'sent', 'all', 'archive', or 'drafts'", -> - inputs = ['sent', 'all', 'archive', 'drafts'] + it "doesn't display 'all', 'archive', or 'drafts'", -> + inputs = ['all', 'archive', 'drafts'] actualOut = sortedForCategoryNames inputs expect(actualOut.length).toBe 0 diff --git a/src/flux/models/category.coffee b/src/flux/models/category.coffee index 6883c7eec..28533973f 100644 --- a/src/flux/models/category.coffee +++ b/src/flux/models/category.coffee @@ -18,11 +18,11 @@ StandardCategories = { LockedCategories = { "sent" + "drafts" "N1-Snoozed" } HiddenCategories = { - "sent" "drafts" "all" "archive" diff --git a/src/mailbox-perspective.coffee b/src/mailbox-perspective.coffee index 4e4d17091..4e2095aaf 100644 --- a/src/mailbox-perspective.coffee +++ b/src/mailbox-perspective.coffee @@ -305,14 +305,17 @@ class CategoryMailboxPerspective extends MailboxPerspective receiveThreads: (threadsOrIds) => FocusedPerspectiveStore = require './flux/stores/focused-perspective-store' - currentCategories = FocusedPerspectiveStore.current().categories() + current= FocusedPerspectiveStore.current() # This assumes that the we don't have more than one category per accountId # attached to this perspective DatabaseStore.modelify(Thread, threadsOrIds).then (threads) => tasks = TaskFactory.tasksForApplyingCategories threads: threads - categoriesToRemove: (accountId) -> _.filter(currentCategories, _.matcher({accountId})) + categoriesToRemove: (accountId) -> + if current.categoriesSharedName() in Category.LockedCategoryNames + return [] + return _.filter(current.categories(), _.matcher({accountId})) categoriesToAdd: (accountId) => [_.findWhere(@_categories, {accountId})] Actions.queueTasks(tasks)