// Received/read indicator. import React from 'react'; import { defineMessages, injectIntl } from 'react-intl'; import Tinode from 'tinode-sdk'; import { shortDateFormat } from '../lib/strformat.js'; const messages = defineMessages({ 'sending': { 'id': 'message_sending', 'defaultMessage': 'sending...', 'description': 'Message being sent, in place of time stamp' }, 'failed': { 'id': 'message_sending_failed', 'defaultMessage': 'failed', 'description': 'Failed to send message, in place of time stamp' } }); class ReceivedMarker extends React.PureComponent { render() { const {formatMessage} = this.props.intl; let timestamp; if (this.props.received <= Tinode.MESSAGE_STATUS_SENDING) { timestamp = formatMessage(messages.sending); } else if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) { timestamp = formatMessage(messages.failed); } else { timestamp = shortDateFormat(this.props.timestamp, this.props.intl.locale); } let marker = null; if (this.props.received <= Tinode.MESSAGE_STATUS_SENDING) { marker = (access_time); // watch face } else if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) { marker = (warning); // yellow icon /!\ } else if (this.props.received == Tinode.MESSAGE_STATUS_SENT) { marker = (done); // checkmark } else if (this.props.received == Tinode.MESSAGE_STATUS_RECEIVED) { marker = (done_all); // double checkmark } else if (this.props.received == Tinode.MESSAGE_STATUS_READ) { marker = (done_all); // blue double checkmark } return ( {timestamp}{'\u00a0'}{marker} ); } }; export default injectIntl(ReceivedMarker);