import React, { useContext } from 'react';
import { Text, View } from 'react-native';
import PropTypes from 'prop-types';
import equal from 'deep-equal';
import I18n from '../../i18n';
import styles from './styles';
import Markdown from '../markdown';
import { getInfoMessage } from './utils';
import { themes } from '../../constants/colors';
import MessageContext from './Context';
const Content = React.memo((props) => {
if (props.isInfo) {
const infoMessage = getInfoMessage({ ...props });
return (
{infoMessage}
);
}
let content = null;
if (props.tmid && !props.msg) {
content = {I18n.t('Sent_an_attachment')};
} else {
const { baseUrl, user } = useContext(MessageContext);
content = (
);
}
return (
{content}
);
}, (prevProps, nextProps) => {
if (prevProps.isTemp !== nextProps.isTemp) {
return false;
}
if (prevProps.msg !== nextProps.msg) {
return false;
}
if (prevProps.theme !== nextProps.theme) {
return false;
}
if (!equal(prevProps.mentions, nextProps.mentions)) {
return false;
}
if (!equal(prevProps.channels, nextProps.channels)) {
return false;
}
return true;
});
Content.propTypes = {
isTemp: PropTypes.bool,
isInfo: PropTypes.bool,
tmid: PropTypes.string,
isThreadRoom: PropTypes.bool,
msg: PropTypes.string,
theme: PropTypes.string,
isEdited: PropTypes.bool,
getCustomEmoji: PropTypes.func,
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
navToRoomInfo: PropTypes.func,
useRealName: PropTypes.bool
};
Content.displayName = 'MessageContent';
export default Content;