Mailspring/internal_packages/thread-list/lib/thread-list-participants.cjsx
Ben Gotow dff5465931 fix(*) Small visual tweaks and fixes - see summary
Summary:
ThreadStore should be done loading as soon as threads are available

SearchSuggestionStore should use ContactsStore for contact results

Contact Store should not "filter all, take 10" it should only filter until it has 10. It should also check against "Ben Gotow" as well as "Ben" and "Gotow", so I can type "Ben Go"

Sometimes participants are "Ben Gotow <ben@g.com>", "ben@g.com". If we get zero contacts after removing Me, put "Me" back in...

Fix "Update Available" notification, broken reference to `atom.views.getView(atom.workspace)`

A bit more debugging around cursors. Need to handle this case soon.

Only use atomWorkspace if it exists.

Fix for dragging next to / around toolbar window controls

Consolidate the display of Contacts in menus into a single MenuItem subclass

Update Template Popover styling

fetchFromCache should only remove thread loading indicator *IF* it found results in the cache. Doh...

Give the thread list "Name" column a fixed width (mg)

Better styling of message list collapsed mode, rage against user selection and cursor: pointer

Occasionally admin.inboxapp.com returns bogus data

Sebaastian feedback on thread list

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1350
2015-03-25 18:22:52 -07:00

81 lines
2.2 KiB
CoffeeScript

React = require 'react'
_ = require 'underscore-plus'
{NamespaceStore} = require 'inbox-exports'
module.exports =
ThreadListParticipants = React.createClass
displayName: 'ThreadListParticipants'
propTypes:
thread: React.PropTypes.object.isRequired
render: ->
items = @getParticipants()
count = []
if @props.thread.messageMetadata and @props.thread.messageMetadata.length > 1
count = " (#{@props.thread.messageMetadata.length})"
chips = items.map (item, idx) ->
if item.spacer
<span key={idx}>...</span>
else
if item.name.length > 0
if items.length > 1
short = item.displayFirstName()
else
short = item.displayName()
else
short = item.email
if idx < items.length-1 and not items[idx+1].spacer
short += ", "
<span key={idx} className="unread-#{item.unread}">{short}</span>
<div className="participants">
{chips}{count}
</div>
shouldComponentUpdate: (newProps, newState) ->
!_.isEqual(newProps.thread, @props.thread)
getParticipants: ->
if @props.thread.messageMetadata
list = []
last = null
for msg in @props.thread.messageMetadata
from = msg.from[0]
continue unless from
if from.email isnt last
from.unread = msg.unread
list.push(from)
last = from.email
else
list = @props.thread.participants
return [] unless list and list instanceof Array
me = NamespaceStore.current().emailAddress
list = _.reject list, (p) -> p.email is me
# Removing "Me" may remove "Me" several times due to the way
# participants is created. If we're left with an empty array,
# put one a "Me" back in.
if list.length is 0
list.push(@props.thread.participants[0])
# We only ever want to show three. Ben...Kevin... Marty
# But we want the *right* three.
if list.length > 3
listTrimmed = []
# Always include the first item
listTrimmed.push(list[0])
listTrimmed.push({spacer: true})
# Always include the last two item
listTrimmed.push(list[list.length - 2])
listTrimmed.push(list[list.length - 1])
list = listTrimmed
list