2019-05-20 20:43:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View, Text } from 'react-native';
|
|
|
|
import removeMarkdown from 'remove-markdown';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-01-29 20:20:36 +00:00
|
|
|
import shortnameToUnicode from '../../utils/shortnameToUnicode';
|
2019-05-20 20:43:50 +00:00
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
|
|
|
import DisclosureIndicator from '../DisclosureIndicator';
|
|
|
|
import styles from './styles';
|
2019-12-11 23:01:12 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
2019-05-20 20:43:50 +00:00
|
|
|
|
|
|
|
const RepliedThread = React.memo(({
|
2019-12-11 23:01:12 +00:00
|
|
|
tmid, tmsg, isHeader, fetchThreadName, id, theme
|
2019-05-20 20:43:50 +00:00
|
|
|
}) => {
|
2019-12-11 23:01:12 +00:00
|
|
|
if (!tmid || !isHeader) {
|
2019-05-20 20:43:50 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tmsg) {
|
2019-10-07 20:56:30 +00:00
|
|
|
fetchThreadName(tmid, id);
|
2019-05-20 20:43:50 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-10-07 20:56:30 +00:00
|
|
|
let msg = shortnameToUnicode(tmsg);
|
2019-05-20 20:43:50 +00:00
|
|
|
msg = removeMarkdown(msg);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.repliedThread} testID={`message-thread-replied-on-${ msg }`}>
|
2019-12-11 23:01:12 +00:00
|
|
|
<CustomIcon name='thread' size={20} style={styles.repliedThreadIcon} color={themes[theme].tintColor} />
|
|
|
|
<Text style={[styles.repliedThreadName, { color: themes[theme].tintColor }]} numberOfLines={1}>{msg}</Text>
|
|
|
|
<DisclosureIndicator theme={theme} />
|
2019-05-20 20:43:50 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}, (prevProps, nextProps) => {
|
|
|
|
if (prevProps.tmid !== nextProps.tmid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.tmsg !== nextProps.tmsg) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.isHeader !== nextProps.isHeader) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-11 23:01:12 +00:00
|
|
|
if (prevProps.theme !== nextProps.theme) {
|
2019-05-20 20:43:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
RepliedThread.propTypes = {
|
|
|
|
tmid: PropTypes.string,
|
|
|
|
tmsg: PropTypes.string,
|
2019-10-07 20:56:30 +00:00
|
|
|
id: PropTypes.string,
|
2019-05-20 20:43:50 +00:00
|
|
|
isHeader: PropTypes.bool,
|
2019-12-11 23:01:12 +00:00
|
|
|
theme: PropTypes.string,
|
2019-05-20 20:43:50 +00:00
|
|
|
fetchThreadName: PropTypes.func
|
|
|
|
};
|
|
|
|
RepliedThread.displayName = 'MessageRepliedThread';
|
|
|
|
|
|
|
|
export default RepliedThread;
|