_ = require 'underscore-plus'
React = require "react"
module.exports =
MessageParticipants = React.createClass
displayName: 'MessageParticipants'
render: ->
{@_formattedParticipants()}
_formattedParticipants: ->
From:
{@_joinNames(@props.from)}
{if @_isToEveryone() then @_toEveryone() else @_toSome()}
_toEveryone: ->
To:
Everyone
_toSome: ->
if @props.cc.length > 0
cc_spans =
CC:
{@_joinNames(@props.cc)}
To:
{@_joinNames(@props.to)}
{cc_spans}
_joinNames: (contacts=[]) ->
_.map(contacts, (c) -> c.displayFirstName()).join(", ")
_isToEveryone: ->
mp = _.map(@props.message_participants, (c) -> c.email)
tp = _.map(@props.thread_participants, (c) -> c.email)
mp.length > 10 and _.difference(tp, mp).length is 0