diff --git a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee index e6073a452..e68931c55 100644 --- a/internal_packages/account-sidebar/lib/account-sidebar-store.coffee +++ b/internal_packages/account-sidebar/lib/account-sidebar-store.coffee @@ -60,13 +60,14 @@ AccountSidebarStore = Reflux.createStore # Some tags don't have unread counts return if tag.id in ['archive', 'drafts', 'sent', 'trash'] - DatabaseStore.count(Thread, [ - Thread.attributes.namespaceId.equal(namespace.id), - Thread.attributes.unread.equal(true), - Thread.attributes.tags.contains(tag.id), - ]).then (count) => - @_unreadCounts[tag.id] = count - @trigger(@) + # Make a web request for unread count + atom.inbox.makeRequest + method: 'GET' + path: "/n/#{namespace.id}/tags/#{tag.id}" + success: (json) => + tag = (new Tag).fromJSON(json) + @_unreadCounts[tag.id] = tag.unreadCount + @trigger(@) # Unfortunately, the joins necessary to compute unread counts are expensive. # Rather than update unread counts every time threads change in the database, diff --git a/src/flux/models/tag.coffee b/src/flux/models/tag.coffee index 23e1eafb6..b187de81c 100644 --- a/src/flux/models/tag.coffee +++ b/src/flux/models/tag.coffee @@ -8,5 +8,13 @@ class Tag extends Model 'name': Attributes.String queryable: true modelKey: 'name' + 'readonly': Attributes.Boolean + modelKey: 'readonly' + 'unreadCount': Attributes.Number + modelKey: 'unreadCount' + jsonKey: 'unread_count' + 'threadCount': Attributes.Number + modelKey: 'threadCount' + jsonKey: 'thread_count' module.exports = Tag \ No newline at end of file