2019-05-20 20:43:50 +00:00
|
|
|
import React from 'react';
|
2019-07-17 14:06:39 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2019-05-20 20:43:50 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import styles from './styles';
|
|
|
|
import Markdown from './Markdown';
|
|
|
|
import { getInfoMessage } from './utils';
|
|
|
|
|
|
|
|
const Content = React.memo((props) => {
|
|
|
|
if (props.isInfo) {
|
|
|
|
return <Text style={styles.textInfo}>{getInfoMessage({ ...props })}</Text>;
|
|
|
|
}
|
|
|
|
|
2019-07-17 14:06:39 +00:00
|
|
|
let content = null;
|
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
if (props.tmid && !props.msg) {
|
2019-07-17 14:06:39 +00:00
|
|
|
content = <Text style={styles.text}>{I18n.t('Sent_an_attachment')}</Text>;
|
|
|
|
} else {
|
|
|
|
content = (
|
|
|
|
<Markdown
|
|
|
|
msg={props.msg}
|
|
|
|
baseUrl={props.baseUrl}
|
|
|
|
username={props.user.username}
|
|
|
|
isEdited={props.isEdited}
|
|
|
|
mentions={props.mentions}
|
|
|
|
channels={props.channels}
|
|
|
|
numberOfLines={props.tmid ? 1 : 0}
|
|
|
|
getCustomEmoji={props.getCustomEmoji}
|
|
|
|
useMarkdown={props.useMarkdown}
|
|
|
|
/>
|
|
|
|
);
|
2019-05-20 20:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2019-07-17 14:06:39 +00:00
|
|
|
<View style={props.isTemp && styles.temp}>
|
|
|
|
{content}
|
|
|
|
</View>
|
2019-05-20 20:43:50 +00:00
|
|
|
);
|
2019-07-17 14:06:39 +00:00
|
|
|
}, (prevProps, nextProps) => prevProps.isTemp === nextProps.isTemp && prevProps.msg === nextProps.msg);
|
2019-05-20 20:43:50 +00:00
|
|
|
|
|
|
|
Content.propTypes = {
|
2019-07-17 14:06:39 +00:00
|
|
|
isTemp: PropTypes.bool,
|
2019-05-20 20:43:50 +00:00
|
|
|
isInfo: PropTypes.bool,
|
|
|
|
isEdited: PropTypes.bool,
|
|
|
|
useMarkdown: PropTypes.bool,
|
|
|
|
tmid: PropTypes.string,
|
|
|
|
msg: PropTypes.string,
|
|
|
|
baseUrl: PropTypes.string,
|
|
|
|
user: PropTypes.object,
|
|
|
|
mentions: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
|
|
channels: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
|
|
getCustomEmoji: PropTypes.func
|
|
|
|
};
|
|
|
|
Content.displayName = 'MessageContent';
|
|
|
|
|
|
|
|
export default Content;
|