diff --git a/internal_packages/account-sidebar/lib/account-sidebar-mail-view-item.cjsx b/internal_packages/account-sidebar/lib/account-sidebar-mail-view-item.cjsx
index 2ce94377c..f2bc6f61e 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar-mail-view-item.cjsx
+++ b/internal_packages/account-sidebar/lib/account-sidebar-mail-view-item.cjsx
@@ -2,7 +2,7 @@ React = require 'react'
classNames = require 'classnames'
{Actions,
Utils,
- UnreadCountStore,
+ ThreadCountsStore,
WorkspaceStore,
AccountStore,
FocusedMailViewStore,
@@ -17,29 +17,16 @@ class AccountSidebarMailViewItem extends React.Component
@propTypes:
select: React.PropTypes.bool
item: React.PropTypes.object.isRequired
+ itemUnreadCount: React.PropTypes.number
mailView: React.PropTypes.object.isRequired
constructor: (@props) ->
- @state =
- unreadCount: UnreadCountStore.count() ? 0
-
- componentWillMount: =>
- @_usub = UnreadCountStore.listen @_onUnreadCountChange
-
- componentWillUnmount: =>
- @_usub()
-
- _onUnreadCountChange: =>
- @setState unreadCount: UnreadCountStore.count()
+ @state = {}
shouldComponentUpdate: (nextProps, nextState) =>
!Utils.isEqualReact(@props, nextProps) or !Utils.isEqualReact(@state, nextState)
render: =>
- unread = []
- if @props.mailView.category?.name is "inbox" and @state.unreadCount > 0
- unread =
{@state.unreadCount}
-
containerClass = classNames
'item': true
'selected': @props.select
@@ -51,12 +38,17 @@ class AccountSidebarMailViewItem extends React.Component
shouldAcceptDrop={@_shouldAcceptDrop}
onDragStateChange={ ({isDropping}) => @setState({isDropping}) }
onDrop={@_onDrop}>
- {unread}
-
+ {@_renderUnreadCount()}
{@_renderIcon()}
{@props.item.name}
+ _renderUnreadCount: =>
+ return false if @props.itemUnreadCount is 0
+ className = 'item-count-box '
+ className += @props.mailView.category?.name
+ {@props.itemUnreadCount}
+
_renderIcon: ->
diff --git a/internal_packages/account-sidebar/lib/account-sidebar.cjsx b/internal_packages/account-sidebar/lib/account-sidebar.cjsx
index 51686b522..7dfbfafee 100644
--- a/internal_packages/account-sidebar/lib/account-sidebar.cjsx
+++ b/internal_packages/account-sidebar/lib/account-sidebar.cjsx
@@ -1,6 +1,6 @@
React = require 'react'
_ = require 'underscore'
-{Actions, MailViewFilter, WorkspaceStore} = require("nylas-exports")
+{Actions, MailViewFilter, WorkspaceStore, ThreadCountsStore} = require("nylas-exports")
{ScrollRegion, Flexbox} = require("nylas-component-kit")
SidebarDividerItem = require("./account-sidebar-divider-item")
SidebarSheetItem = require("./account-sidebar-sheet-item")
@@ -38,9 +38,12 @@ class AccountSidebar extends React.Component
componentDidMount: =>
@unsubscribers = []
@unsubscribers.push AccountSidebarStore.listen @_onStoreChange
+ @unsubscribers.push ThreadCountsStore.listen @_onStoreChange
+ @configSubscription = NylasEnv.config.observe('core.workspace.showUnreadForAllCategories', @_onStoreChange)
componentWillUnmount: =>
unsubscribe() for unsubscribe in @unsubscribers
+ @configSubscription?.dispose()
render: =>