// @flow import React from 'react'; import { translate } from '../../../base/i18n'; import Message from '../../../base/react/components/web/Message'; import { MESSAGE_TYPE_LOCAL } from '../../constants'; import AbstractChatMessage, { type Props } from '../AbstractChatMessage'; import PrivateMessageButton from './PrivateMessageButton'; /** * Renders a single chat message. */ class ChatMessage extends AbstractChatMessage { /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { message, t } = this.props; return (
{ this.props.showDisplayName && this._renderDisplayName() }
{ this.props.message.displayName === this.props.message.recipient ? t('chat.messageAccessibleTitleMe') : t('chat.messageAccessibleTitle', { user: this.props.message.displayName }) }
{ message.privateMessage && this._renderPrivateNotice() }
{ message.privateMessage && message.messageType !== MESSAGE_TYPE_LOCAL && (
) }
{ this.props.showTimestamp && this._renderTimestamp() }
); } _getFormattedTimestamp: () => string; _getMessageText: () => string; _getPrivateNoticeMessage: () => string; /** * Renders the display name of the sender. * * @returns {React$Element<*>} */ _renderDisplayName() { return (
{ this.props.message.displayName }
); } /** * Renders the message privacy notice. * * @returns {React$Element<*>} */ _renderPrivateNotice() { return (
{ this._getPrivateNoticeMessage() }
); } /** * Renders the time at which the message was sent. * * @returns {React$Element<*>} */ _renderTimestamp() { return (
{ this._getFormattedTimestamp() }
); } } export default translate(ChatMessage);