Mailspring/internal_packages/inbox-contact-elements/lib/Participants.cjsx
dillon 07996da960 add more test coverage and refactor checking if a contact is the current user. fixes T3360.
Summary: @evan -- would love to get your opinion on this approach!

Test Plan: add new tests

Reviewers: evan

Reviewed By: evan

Subscribers: evan

Maniphest Tasks: T3360

Differential Revision: https://phab.nylas.com/D1904
2015-08-18 10:18:30 -07:00

42 lines
944 B
CoffeeScript

React = require "react"
_ = require "underscore"
ContactChip = require './ContactChip'
# Parameters
# clickable (optional) - is this currently clickable?
# thread (optional) - thread context for sorting
# passed into the ParticipantChip
# - 'primary'
# - 'list'
class Participants extends React.Component
@displayName: "Participants"
@containerRequired: false
render: =>
chips = @getParticipants().map (p) =>
<ContactChip key={p.toString()} clickable={@props.clickable} participant={p} />
<span>
{chips}
</span>
getParticipants: =>
list = @props.participants
# Remove 'Me' if there is more than one participant
if list.length > 1
list = _.reject list, (contact) -> contact.isMe()
list.forEach (p) ->
p.id = p.name+p.email
list
shouldComponentUpdate: (newProps, newState) =>
!_.isEqual(newProps.participants, @props.participants)
module.exports = Participants