Mailspring/internal_packages/sidebar-fullcontact/lib/sidebar-fullcontact.cjsx
Evan Morikawa 00631b2e99 feat(sidebar): add FullContact and Salesforce sidebar
Summary:
store not intelligently figures out the most relevant contact

fix primary contact logic

styling on contactstore

can select different people on the sidebar

add salesforce stub

put return statement back in checking for Salesforce Token

salesforce sidebar loads real data now

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1319
2015-03-19 17:21:09 -07:00

64 lines
1.7 KiB
CoffeeScript

_ = require 'underscore-plus'
React = require "react"
FullContactStore = require "./fullcontact-store"
SidebarFullContactDetails = require "./sidebar-fullcontact-details.cjsx"
{Actions} = require("inbox-exports")
module.exports =
SidebarFullContact = React.createClass
getInitialState: ->
fullContactCache: {}
sortedContacts: []
focusedContact: null
componentDidMount: ->
@unsubscribe = FullContactStore.listen @_onChange
componentWillUnmount: ->
@unsubscribe()
render: ->
<div className="full-contact-sidebar">
<SidebarFullContactDetails contact={@state.focusedContact ? {}}
fullContact={@_fullContact()}/>
<div className="other-contacts">
<h2 className="sidebar-h2">Thread Participants</h2>
{@_renderSortedContacts()}
</div>
</div>
_renderSortedContacts: ->
contacts = []
@state.sortedContacts.forEach (contact) =>
if contact is @state.focusedContact
selected = "selected"
else selected = ""
contacts.push(
<div className="other-contact #{selected}"
onClick={=> @_onSelectContact(contact)}
key={contact.id}>
{contact.name}
</div>
)
return contacts
_onSelectContact: (contact) ->
Actions.focusContact(contact)
_fullContact: ->
if @state.focusedContact?.email
return @state.fullContactCache[@state.focusedContact.email] ? {}
else
return {}
_onChange: ->
@setState(@_getStateFromStores())
_getStateFromStores: ->
fullContactCache: FullContactStore.fullContactCache()
sortedContacts: FullContactStore.sortedContacts()
focusedContact: FullContactStore.focusedContact()