Mailspring/internal_packages/thread-list/lib/thread-list-icon.cjsx
Ben Gotow 3f3ec441ae feat(important): Improtant flags you can enable optionally for Gmail accounts
Summary: Fixes T3477

Test Plan: Tests are forthcoming

Reviewers: dillon, evan

Reviewed By: evan

Maniphest Tasks: T3477

Differential Revision: https://phab.nylas.com/D1990
2015-09-08 10:53:07 -07:00

56 lines
1.4 KiB
CoffeeScript

_ = require 'underscore'
React = require 'react'
{Actions,
Utils,
Thread,
ChangeStarredTask,
AccountStore} = require 'nylas-exports'
class ThreadListIcon extends React.Component
@displayName: 'ThreadListIcon'
@propTypes:
thread: React.PropTypes.object
_iconType: =>
if !@props.thread
return 'thread-icon-star-on-hover'
if @props.thread.starred
return 'thread-icon-star'
if @props.thread.unread
return 'thread-icon-unread thread-icon-star-on-hover'
msgs = @_nonDraftMessages()
last = msgs[msgs.length - 1]
if msgs.length > 1 and last.from[0]?.isMe()
if Utils.isForwardedMessage(last)
return 'thread-icon-forwarded thread-icon-star-on-hover'
else
return 'thread-icon-replied thread-icon-star-on-hover'
return 'thread-icon-none thread-icon-star-on-hover'
_nonDraftMessages: =>
msgs = @props.thread.metadata
return [] unless msgs and msgs instanceof Array
msgs = _.filter msgs, (m) -> m.serverId and not m.draft
return msgs
shouldComponentUpdate: (nextProps) =>
return false if nextProps.thread is @props.thread
true
render: =>
<div className="thread-icon #{@_iconType()}" onClick={@_onToggleStar}></div>
_onToggleStar: (event) =>
task = new ChangeStarredTask(thread: @props.thread, starred: !@props.thread.starred)
Actions.queueTask(task)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = ThreadListIcon