mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 00:06:06 +08:00
fix(message-list): Only display labels when usesLabels()
This commit is contained in:
parent
7ef187e882
commit
da68b393a2
|
@ -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]
|
||||
|
|
|
@ -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
|
|||
</div>
|
||||
|
||||
_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) =>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue