// A single topic or user. import React from 'react'; import { FormattedMessage } from 'react-intl'; import LetterTile from './letter-tile.jsx'; import ContactBadges from './contact-badges.jsx'; import UnreadBadge from './unread-badge.jsx'; export default class Contact extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); this.handleContextClick = this.handleContextClick.bind(this); } handleClick(e) { e.preventDefault(); e.stopPropagation(); if (this.props.onSelected) { this.props.onSelected(this.props.item, this.props.index, this.props.now, this.props.acs); } } handleContextClick(e) { e.preventDefault(); e.stopPropagation(); this.props.showContextMenu({ topicName: this.props.item, y: e.pageY, x: e.pageX }); } render() { let title = this.props.title; if (!title) { title = ; } else if (title.length > 30) { // FIXME: this is probably wrong for RTL languages. title = title.substring(0, 28) + '...'; } const online = this.props.now ? 'online' : 'offline'; const avatar = this.props.avatar ? this.props.avatar : true; const badges = this.props.badges ? this.props.badges.slice() : []; if (this.props.showMode && this.props.acs) { badges.push({name: this.props.acs.getMode(), key: 'mode'}); } return (
  • {this.props.showOnline ? : (this.props.showCheckmark && this.props.selected ? check_circle : null)}
    {title} {this.props.unread > 0 ? : null}
    {this.props.comment ?
    {this.props.comment}
    : null}
    {this.props.showContextMenu ? expand_more : null}
  • ); } };