fix(important): Fix bugs in "important" label categorization

This commit is contained in:
Ben Gotow 2016-01-28 15:27:03 -08:00
parent 09a2096690
commit e27c9eaca5
3 changed files with 22 additions and 12 deletions

View file

@ -65,10 +65,9 @@ c3 = new ListTabular.Column
attachment = <div className="thread-icon thread-icon-attachment"></div>
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

View file

@ -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] ?= {}

View file

@ -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)