Mailspring/internal_packages/thread-list/lib/draft-list-sidebar-item.cjsx
dillon 1b929ec91d fix(draft-list-sidebar-item): draft count renders correctly. fixes T3480.
Summary: I think I might've broken this when I fixed T3402, but I didn't realize it because I had zero drafts at the time, so this component didn't render for me.

Test Plan: tested manually

Reviewers: bengotow

Maniphest Tasks: T3402, T3480

Differential Revision: https://phab.nylas.com/D1965
2015-09-01 12:32:39 -07:00

44 lines
1.2 KiB
CoffeeScript

React = require 'react'
_ = require 'underscore'
classNames = require 'classnames'
{Actions, Utils, WorkspaceStore, DraftCountStore} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
class DraftListSidebarItem extends React.Component
@displayName: 'DraftListSidebarItem'
constructor: (@props) ->
@state = @getStateFromStores()
componentDidMount: =>
@unsubscribe = DraftCountStore.listen(@_onCountChanged)
componentWillUnmount: =>
@unsubscribe()
getStateFromStores: =>
count: DraftCountStore.count()
_onCountChanged: =>
@setState(@getStateFromStores())
render: =>
classSet = classNames
'item': true
'selected': @props.select
unread = []
if @state.count > 0
unread = <div className="unread item-count-box">{@state.count}</div>
<div className={classSet} onClick={@_onClick}>
{unread}
<div className="icon"><RetinaImg name={'drafts.png'} mode={RetinaImg.Mode.ContentIsMask} /></div>
<div className="name"> {@props.item.name}</div>
</div>
_onClick: (event) =>
event.preventDefault()
Actions.selectRootSheet(@props.item)
module.exports = DraftListSidebarItem