import React, { Component } from 'react'; import Autolinker from 'autolinker'; import { timestamp } from '../util'; export default class MessageHeader extends Component { shouldComponentUpdate(nextProps) { return nextProps.message.lines[0] !== this.props.message.lines[0]; } handleSenderClick = () => { const { message, openPrivateChat, select } = this.props; openPrivateChat(message.server, message.from); select(message.server, message.from, true); } render() { const { message } = this.props; const line = Autolinker.link(message.lines[0], { stripPrefix: false }); let sender = null; let messageClass = 'message'; if (message.from) { sender = ( {' '} {message.from} ); } if (message.type) { messageClass += ' message-' + message.type; } return (
{timestamp(message.time)} {sender}
); } }