2015-06-09 08:02:50 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
{Actions,
|
|
|
|
Utils,
|
|
|
|
Thread,
|
2015-08-06 06:53:08 +08:00
|
|
|
ChangeStarredTask,
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
AccountStore} = require 'nylas-exports'
|
2015-06-09 08:02:50 +08:00
|
|
|
|
|
|
|
class ThreadListIcon extends React.Component
|
|
|
|
@displayName: 'ThreadListIcon'
|
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object
|
|
|
|
|
|
|
|
_iconType: =>
|
2015-06-20 02:31:27 +08:00
|
|
|
if !@props.thread
|
|
|
|
return 'thread-icon-star-on-hover'
|
2015-06-09 08:02:50 +08:00
|
|
|
|
2015-07-16 23:54:20 +08:00
|
|
|
if @props.thread.starred
|
2015-06-09 08:02:50 +08:00
|
|
|
return 'thread-icon-star'
|
2015-06-10 01:35:21 +08:00
|
|
|
|
|
|
|
if @props.thread.unread
|
2015-09-05 03:23:15 +08:00
|
|
|
return 'thread-icon-unread thread-icon-star-on-hover'
|
2015-06-10 01:35:21 +08:00
|
|
|
|
|
|
|
msgs = @_nonDraftMessages()
|
|
|
|
last = msgs[msgs.length - 1]
|
|
|
|
|
2015-08-21 07:20:42 +08:00
|
|
|
if msgs.length > 1 and last.from[0]?.isMe()
|
2015-06-10 01:35:21 +08:00
|
|
|
if Utils.isForwardedMessage(last)
|
2015-09-05 03:23:15 +08:00
|
|
|
return 'thread-icon-forwarded thread-icon-star-on-hover'
|
2015-06-10 01:35:21 +08:00
|
|
|
else
|
2015-09-05 03:23:15 +08:00
|
|
|
return 'thread-icon-replied thread-icon-star-on-hover'
|
2015-06-10 01:35:21 +08:00
|
|
|
|
2015-09-09 01:53:07 +08:00
|
|
|
return 'thread-icon-none thread-icon-star-on-hover'
|
2015-06-10 01:35:21 +08:00
|
|
|
|
|
|
|
_nonDraftMessages: =>
|
|
|
|
msgs = @props.thread.metadata
|
|
|
|
return [] unless msgs and msgs instanceof Array
|
2015-08-29 02:12:53 +08:00
|
|
|
msgs = _.filter msgs, (m) -> m.serverId and not m.draft
|
2015-06-10 01:35:21 +08:00
|
|
|
return msgs
|
2015-06-09 08:02:50 +08:00
|
|
|
|
2015-08-04 05:09:29 +08:00
|
|
|
shouldComponentUpdate: (nextProps) =>
|
|
|
|
return false if nextProps.thread is @props.thread
|
|
|
|
true
|
|
|
|
|
2015-06-09 08:02:50 +08:00
|
|
|
render: =>
|
2015-10-22 02:03:27 +08:00
|
|
|
<div className="thread-icon #{@_iconType()}"
|
|
|
|
title="Star"
|
|
|
|
onClick={@_onToggleStar}></div>
|
2015-06-09 08:02:50 +08:00
|
|
|
|
|
|
|
_onToggleStar: (event) =>
|
2015-08-06 06:53:08 +08:00
|
|
|
task = new ChangeStarredTask(thread: @props.thread, starred: !@props.thread.starred)
|
2015-07-16 23:54:20 +08:00
|
|
|
Actions.queueTask(task)
|
2015-06-09 08:02:50 +08:00
|
|
|
|
|
|
|
# Don't trigger the thread row click
|
|
|
|
event.stopPropagation()
|
|
|
|
|
|
|
|
module.exports = ThreadListIcon
|