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
This commit is contained in:
Juan Tejada 2016-02-24 11:43:51 -08:00
parent 630448634c
commit 300d5dbc7f
2 changed files with 7 additions and 2 deletions

View file

@ -115,10 +115,13 @@ class SidebarItem
id += "-#{opts.name}" if opts.name id += "-#{opts.name}" if opts.name
opts.name = "Snoozed" unless opts.name opts.name = "Snoozed" unless opts.name
opts.iconName= 'snooze.png' opts.iconName= 'snooze.png'
categories = accountIds.map (accId) => categories = accountIds.map (accId) =>
_.findWhere CategoryStore.userCategories(accId), {displayName} _.findWhere CategoryStore.userCategories(accId), {displayName}
categories = _.compact(categories)
perspective = MailboxPerspective.forCategories(categories) perspective = MailboxPerspective.forCategories(categories)
perspective.name = id unless perspective.name
@forPerspective(id, perspective, opts) @forPerspective(id, perspective, opts)
@forStarred: (accountIds, opts = {}) -> @forStarred: (accountIds, opts = {}) ->

View file

@ -18,6 +18,7 @@ StandardCategories = {
LockedCategories = { LockedCategories = {
"sent" "sent"
"N1-Snoozed"
} }
HiddenCategories = { HiddenCategories = {
@ -27,6 +28,7 @@ HiddenCategories = {
"archive" "archive"
"starred" "starred"
"important" "important"
"N1-Snoozed"
} }
AllMailName = "all" AllMailName = "all"
@ -110,10 +112,10 @@ class Category extends Model
StandardCategories[@name]? and @name isnt 'important' StandardCategories[@name]? and @name isnt 'important'
isLockedCategory: -> isLockedCategory: ->
LockedCategories[@name]? LockedCategories[@name]? or LockedCategories[@displayName]?
isHiddenCategory: -> isHiddenCategory: ->
HiddenCategories[@name]? HiddenCategories[@name]? or HiddenCategories[@displayName]?
isUserCategory: -> isUserCategory: ->
not @isStandardCategory() and not @isHiddenCategory() not @isStandardCategory() and not @isHiddenCategory()