diff --git a/internal_packages/thread-list/lib/thread-list-columns.cjsx b/internal_packages/thread-list/lib/thread-list-columns.cjsx index cf8a85719..aa4a4a3a2 100644 --- a/internal_packages/thread-list/lib/thread-list-columns.cjsx +++ b/internal_packages/thread-list/lib/thread-list-columns.cjsx @@ -65,10 +65,9 @@ c3 = new ListTabular.Column attachment =
currentCategories = FocusedPerspectiveStore.current().categories() ? [] - account = FocusedPerspectiveStore.current().account - ignoredIds = _.pluck(currentCategories, 'id') - ignoredIds.push(cat.id) for cat in CategoryStore.hiddenCategories(account) + ignored = [].concat(currentCategories, CategoryStore.hiddenCategories(thread.accountId)) + ignoredIds = _.pluck(ignored, 'id') for label in (thread.sortedCategories()) continue if label.id in ignoredIds diff --git a/src/flux/stores/category-store.coffee b/src/flux/stores/category-store.coffee index 34663f60d..ad3f31203 100644 --- a/src/flux/stores/category-store.coffee +++ b/src/flux/stores/category-store.coffee @@ -6,8 +6,13 @@ Account = require '../models/account' {Categories} = require 'nylas-observables' Rx = require 'rx-lite' -asAccount = (a) -> if a instanceof Account then a else AccountStore.accountForId(a) -asAccountId = (a) -> if a instanceof Account then a.id else a +asAccount = (a) -> + throw new Error("You must pass an Account or Account Id") unless a + if a instanceof Account then a else AccountStore.accountForId(a) + +asAccountId = (a) -> + throw new Error("You must pass an Account or Account Id") unless a + if a instanceof Account then a.id else a class CategoryStore extends NylasStore @@ -17,7 +22,11 @@ class CategoryStore extends NylasStore @_userCategories = {} @_hiddenCategories = {} - @_disposable = Categories + NylasEnv.config.observe 'core.workspace.showImportant', => + return unless @_categoryResult + @_onCategoriesChanged(@_categoryResult) + + Categories .forAllAccounts() .sort() .subscribe(@_onCategoriesChanged) @@ -95,6 +104,7 @@ class CategoryStore extends NylasStore @getStandardCategory(accountOrId, "trash") _onCategoriesChanged: (categories) => + @_categoryResult = categories @_categoryCache = {} for cat in categories @_categoryCache[cat.accountId] ?= {} diff --git a/src/flux/stores/workspace-store.coffee b/src/flux/stores/workspace-store.coffee index 88a0fd91d..12393e7d4 100644 --- a/src/flux/stores/workspace-store.coffee +++ b/src/flux/stores/workspace-store.coffee @@ -55,12 +55,13 @@ class WorkspaceStore extends NylasStore 'navigation:go-to-label' : => ## TODO _setMailViewByName: (categoryName) -> - account = FocusedPerspectiveStore.current().account - category = CategoryStore.getStandardCategory(account, categoryName) - return unless category - view = MailboxPerspective.forCategory(category) - return unless view - Actions.focusMailboxPerspective(view) + accountIds = FocusedPerspectiveStore.current().accountIds + categories = accountIds.map (aid) -> CategoryStore.getStandardCategory(aid, categoryName) + categories = _.compact(categories) + + if categories.length > 0 + view = MailboxPerspective.forCategories(categories) + Actions.focusMailboxPerspective(view) _selectDraftsSheet: -> Actions.selectRootSheet(@Sheet.Drafts)