mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
00c74cd1a9
Summary: There are now two objects, Folders & Labels. These inherit from `Category` (that's what Eben said they were using on the backend). There are two separate tasks. 1. MoveToFolderTask 2. ApplyLabelsTask It turns out that the semantics between the two are quite different. The reverse operation for moving to a folder is a bit tricky. As of 7-8-15, the Tasks are pretty much complete. I need to write tests for them still and do some manual testing in the client. Test Plan: Writing specs Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D1724
53 lines
1.4 KiB
CoffeeScript
53 lines
1.4 KiB
CoffeeScript
_ = require 'underscore'
|
|
React = require 'react'
|
|
{Actions,
|
|
Utils,
|
|
Thread,
|
|
UpdateThreadsTask,
|
|
NamespaceStore} = 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]
|
|
|
|
myEmail = NamespaceStore.current()?.emailAddress
|
|
if msgs.length > 1 and last.from[0]?.email is myEmail
|
|
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-star-on-hover'
|
|
|
|
_nonDraftMessages: =>
|
|
msgs = @props.thread.metadata
|
|
return [] unless msgs and msgs instanceof Array
|
|
msgs = _.filter msgs, (m) -> m.isSaved() and not m.draft
|
|
return msgs
|
|
|
|
render: =>
|
|
<div className="thread-icon #{@_iconType()}" onClick={@_onToggleStar}></div>
|
|
|
|
_onToggleStar: (event) =>
|
|
values = starred: (not @props.thread.starred)
|
|
task = new UpdateThreadsTask([@props.thread], values)
|
|
Actions.queueTask(task)
|
|
|
|
# Don't trigger the thread row click
|
|
event.stopPropagation()
|
|
|
|
module.exports = ThreadListIcon
|