2015-03-21 07:31:35 +08:00
|
|
|
_ = require 'underscore-plus'
|
|
|
|
React = require "react"
|
|
|
|
|
|
|
|
{Actions, FocusedContactsStore} = require("inbox-exports")
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
class SidebarThreadParticipants extends React.Component
|
|
|
|
@displayName = 'SidebarThreadParticipants'
|
2015-03-21 07:31:35 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state =
|
|
|
|
@_getStateFromStores()
|
2015-03-21 07:31:35 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentDidMount: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
@unsubscribe = FocusedContactsStore.listen @_onChange
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentWillUnmount: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
@unsubscribe()
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
render: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
<div className="sidebar-thread-participants">
|
|
|
|
<h2 className="sidebar-h2">Thread Participants</h2>
|
|
|
|
{@_renderSortedContacts()}
|
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderSortedContacts: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
contacts = []
|
|
|
|
@state.sortedContacts.forEach (contact) =>
|
|
|
|
if contact is @state.focusedContact
|
|
|
|
selected = "selected"
|
|
|
|
else selected = ""
|
|
|
|
contacts.push(
|
|
|
|
<div className="other-contact #{selected}"
|
|
|
|
onClick={=> @_onSelectContact(contact)}
|
2015-04-25 02:33:10 +08:00
|
|
|
key={contact.email+contact.name}>
|
2015-03-21 07:31:35 +08:00
|
|
|
{contact.name}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
return contacts
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onSelectContact: (contact) =>
|
2015-03-21 07:31:35 +08:00
|
|
|
Actions.focusContact(contact)
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onChange: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_getStateFromStores: =>
|
2015-03-21 07:31:35 +08:00
|
|
|
sortedContacts: FocusedContactsStore.sortedContacts()
|
|
|
|
focusedContact: FocusedContactsStore.focusedContact()
|
2015-04-25 02:33:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = SidebarThreadParticipants
|