import { React, PropTypes, DOMUtils, RegExpUtils, Utils } from 'mailspring-exports'; import { RetinaImg } from 'nylas-component-kit'; import ParticipantProfileStore from './participant-profile-store'; export default class SidebarParticipantProfile extends React.Component { static displayName = 'SidebarParticipantProfile'; static propTypes = { contact: PropTypes.object, contactThreads: PropTypes.array, }; static containerStyles = { order: 0, }; constructor(props) { super(props); /* We expect ParticipantProfileStore.dataForContact to return the * following schema: * { * profilePhotoUrl: string * bio: string * location: string * currentTitle: string * currentEmployer: string * socialProfiles: hash keyed by type: ('twitter', 'facebook' etc) * url: string * handle: string * } */ this.state = ParticipantProfileStore.dataForContact(props.contact); } componentDidMount() { this.usub = ParticipantProfileStore.listen(() => { this.setState(ParticipantProfileStore.dataForContact(this.props.contact)); }); } componentWillUnmount() { this.usub(); } _renderProfilePhoto() { if (this.state.profilePhotoUrl) { return (
{title} {this.state.employer}
); } _renderBio() { if (!this.state.bio) { return false; } const bioNodes = []; const hashtagOrMentionRegex = RegExpUtils.hashtagOrMentionRegex(); let bioRemainder = this.state.bio; let match = null; let count = 0; /* I thought we were friends. */ /* eslint no-cond-assign: 0 */ while ((match = hashtagOrMentionRegex.exec(bioRemainder))) { // the first char of the match is whitespace, match[1] is # or @, match[2] is the tag itself. bioNodes.push(bioRemainder.substr(0, match.index + 1)); if (match[1] === '#') { bioNodes.push( {`#${match[2]}`} ); } if (match[1] === '@') { bioNodes.push({`@${match[2]}`}); } bioRemainder = bioRemainder.substr(match.index + match[0].length); count += 1; } bioNodes.push(bioRemainder); return{bioNodes}
; } _renderLocation() { if (!this.state.location) { return false; } return (