import React, { Component } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import PropTypes from 'prop-types'; import moment from 'moment'; import { connect } from 'react-redux'; import Markdown from '../message/Markdown'; import { getCustomEmoji } from '../message/utils'; import { CustomIcon } from '../../lib/Icons'; import sharedStyles from '../../views/Styles'; import { COLOR_PRIMARY, COLOR_BACKGROUND_CONTAINER, COLOR_TEXT_DESCRIPTION, COLOR_WHITE } from '../../constants/colors'; const styles = StyleSheet.create({ container: { flexDirection: 'row', marginTop: 10, backgroundColor: COLOR_WHITE }, messageContainer: { flex: 1, marginHorizontal: 10, backgroundColor: COLOR_BACKGROUND_CONTAINER, paddingHorizontal: 15, paddingVertical: 10, borderRadius: 4 }, header: { flexDirection: 'row', alignItems: 'center' }, username: { color: COLOR_PRIMARY, fontSize: 16, ...sharedStyles.textMedium }, time: { fontSize: 12, lineHeight: 16, marginLeft: 6, ...sharedStyles.textColorDescription, ...sharedStyles.textRegular, fontWeight: '300' }, close: { marginRight: 10 } }); @connect(state => ({ Message_TimeFormat: state.settings.Message_TimeFormat, baseUrl: state.settings.Site_Url || state.server ? state.server.server : '' })) export default class ReplyPreview extends Component { static propTypes = { message: PropTypes.object.isRequired, Message_TimeFormat: PropTypes.string.isRequired, close: PropTypes.func.isRequired, baseUrl: PropTypes.string.isRequired, username: PropTypes.string.isRequired } shouldComponentUpdate() { return false; } close = () => { const { close } = this.props; close(); } render() { const { message, Message_TimeFormat, baseUrl, username } = this.props; const time = moment(message.ts).format(Message_TimeFormat); return ( {message.u.username} {time} ); } }