diff --git a/internal_packages/unread-notifications/lib/main.coffee b/internal_packages/unread-notifications/lib/main.coffee index fb7c1fe42..bf21d8311 100644 --- a/internal_packages/unread-notifications/lib/main.coffee +++ b/internal_packages/unread-notifications/lib/main.coffee @@ -5,6 +5,7 @@ _ = require 'underscore' AccountStore, CategoryStore, SoundRegistry, + FocusedPerspectiveStore, NativeNotifications, DatabaseStore} = require 'nylas-exports' @@ -56,9 +57,14 @@ module.exports = else NylasEnv.displayWindow() - filter = MailboxPerspective.forCategory(thread.categoryNamed('inbox')) + currentCategories = FocusedPerspectiveStore.current().categories() + desiredCategory = thread.categoryNamed('inbox') + + return unless desiredCategory + unless desiredCategory.id in _.pluck(currentCategories, 'id') + filter = MailboxPerspective.forCategory(desiredCategory) Actions.focusMailboxPerspective(filter) - Actions.setFocus(collection: 'thread', item: thread) + Actions.setFocus(collection: 'thread', item: thread) _notifyMessages: -> if @stack.length >= 5 diff --git a/src/flux/models/thread.coffee b/src/flux/models/thread.coffee index d04b0cceb..87893e81c 100644 --- a/src/flux/models/thread.coffee +++ b/src/flux/models/thread.coffee @@ -109,9 +109,10 @@ class Thread extends Model if value @categories = @constructor.attributes.categories.fromJSON(value) - if @participants - for contact in @participants - contact.accountId = @accountId + for attr in ['participants', 'categories'] + value = @[attr] + continue unless value and value instanceof Array + item.accountId = @accountId for item in value @