diff --git a/internal_packages/category-picker/lib/category-picker.cjsx b/internal_packages/category-picker/lib/category-picker.cjsx index 6314368d2..9b6b8aca4 100644 --- a/internal_packages/category-picker/lib/category-picker.cjsx +++ b/internal_packages/category-picker/lib/category-picker.cjsx @@ -301,7 +301,7 @@ class CategoryPicker extends React.Component _categoryUsageCount: (props, categories) => categoryUsageCount = {} - _.flatten(@_threads(props).map(@_threadCategories)).forEach (category) -> + _.flatten(_.pluck(@_threads(props), 'categories')).forEach (category) -> categoryUsageCount[category.id] ?= 0 categoryUsageCount[category.id] += 1 return categoryUsageCount @@ -339,13 +339,6 @@ class CategoryPicker extends React.Component item.numThreads = numThreads item - _threadCategories: (thread) => - if @_account.usesLabels() - return (thread.labels ? []) - else if @_account.usesFolders() - return (thread.folders ? []) - else throw new Error("Invalid organizationUnit") - _threads: (props = @props) => if props.items then return (props.items ? []) else if props.thread then return [props.thread] diff --git a/internal_packages/message-list/lib/message-list.cjsx b/internal_packages/message-list/lib/message-list.cjsx index b12254637..72aa02b1f 100755 --- a/internal_packages/message-list/lib/message-list.cjsx +++ b/internal_packages/message-list/lib/message-list.cjsx @@ -8,6 +8,7 @@ MessageItemContainer = require './message-item-container' Message, DraftStore, MessageStore, + AccountStore, DatabaseStore, WorkspaceStore, ChangeLabelsTask, @@ -244,6 +245,8 @@ class MessageList extends React.Component _renderLabels: => + account = AccountStore.accountForId(@state.currentThread.accountId) + return false unless account.usesLabels() labels = @state.currentThread.sortedCategories() labels = _.reject labels, (l) -> l.name is 'important' labels.map (label) => diff --git a/src/components/mail-important-icon.cjsx b/src/components/mail-important-icon.cjsx index ab506bfa6..1865ab1f8 100644 --- a/src/components/mail-important-icon.cjsx +++ b/src/components/mail-important-icon.cjsx @@ -53,7 +53,7 @@ class MailImportantIcon extends React.Component render: => return false unless @state.visible - isImportant = @state.categoryId and _.findWhere(@props.thread.labels, {id: @state.categoryId})? + isImportant = @state.categoryId and _.findWhere(@props.thread.categories, {id: @state.categoryId})? classes = classNames 'mail-important-icon': true diff --git a/src/flux/attributes/attribute-collection.coffee b/src/flux/attributes/attribute-collection.coffee index c8dc99144..a09e98754 100644 --- a/src/flux/attributes/attribute-collection.coffee +++ b/src/flux/attributes/attribute-collection.coffee @@ -15,7 +15,7 @@ join table associating the ID of the model with the IDs of models in the collect Collection attributes have an additional clause builder, `contains`: ```coffee -DatabaseStore.findAll(Thread).where([Thread.attributes.labels.contains('inbox')]) +DatabaseStore.findAll(Thread).where([Thread.attributes.categories.contains('inbox')]) ``` This is equivalent to writing the following SQL: diff --git a/src/flux/models/query.coffee b/src/flux/models/query.coffee index f46d07b6b..fe37035c2 100644 --- a/src/flux/models/query.coffee +++ b/src/flux/models/query.coffee @@ -25,7 +25,7 @@ query.then (thread) -> ```coffee query = DatabaseStore.findAll(Thread) -query.where([Thread.attributes.labels.contains('label-id')]) +query.where([Thread.attributes.categories.contains('label-id')]) .order([Thread.attributes.lastMessageReceivedTimestamp.descending()]) .limit(100).offset(50) .then (threads) -> diff --git a/src/flux/stores/database-setup-query-builder.coffee b/src/flux/stores/database-setup-query-builder.coffee index b619e27cd..b673bf1e2 100644 --- a/src/flux/stores/database-setup-query-builder.coffee +++ b/src/flux/stores/database-setup-query-builder.coffee @@ -35,7 +35,7 @@ class DatabaseSetupQueryBuilder # Identify collection attributes that can be matched against. These require # JOIN tables. (Right now the only one of these is Thread.folders or - # Thread.labels) + # Thread.categories) collectionAttributes = _.filter attributes, (attr) -> attr.queryable && attr instanceof AttributeCollection collectionAttributes.forEach (attribute) ->