From 300d5dbc7f811a384811a9877f09d18182242027 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 24 Feb 2016 11:43:51 -0800 Subject: [PATCH] fix(sidebar): Prevent error in snooze item when category doesnt exist - Add Snooze category to locked and hidden categories to prevent from directly moving stuff to it and showing up in the user categories section --- internal_packages/account-sidebar/lib/sidebar-item.coffee | 3 +++ src/flux/models/category.coffee | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal_packages/account-sidebar/lib/sidebar-item.coffee b/internal_packages/account-sidebar/lib/sidebar-item.coffee index da5e93f64..feec534ab 100644 --- a/internal_packages/account-sidebar/lib/sidebar-item.coffee +++ b/internal_packages/account-sidebar/lib/sidebar-item.coffee @@ -115,10 +115,13 @@ class SidebarItem id += "-#{opts.name}" if opts.name opts.name = "Snoozed" unless opts.name opts.iconName= 'snooze.png' + categories = accountIds.map (accId) => _.findWhere CategoryStore.userCategories(accId), {displayName} + categories = _.compact(categories) perspective = MailboxPerspective.forCategories(categories) + perspective.name = id unless perspective.name @forPerspective(id, perspective, opts) @forStarred: (accountIds, opts = {}) -> diff --git a/src/flux/models/category.coffee b/src/flux/models/category.coffee index eba041584..a85c818a4 100644 --- a/src/flux/models/category.coffee +++ b/src/flux/models/category.coffee @@ -18,6 +18,7 @@ StandardCategories = { LockedCategories = { "sent" + "N1-Snoozed" } HiddenCategories = { @@ -27,6 +28,7 @@ HiddenCategories = { "archive" "starred" "important" + "N1-Snoozed" } AllMailName = "all" @@ -110,10 +112,10 @@ class Category extends Model StandardCategories[@name]? and @name isnt 'important' isLockedCategory: -> - LockedCategories[@name]? + LockedCategories[@name]? or LockedCategories[@displayName]? isHiddenCategory: -> - HiddenCategories[@name]? + HiddenCategories[@name]? or HiddenCategories[@displayName]? isUserCategory: -> not @isStandardCategory() and not @isHiddenCategory()