2019-05-20 20:43:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { View, Text } from 'react-native';
|
|
|
|
import removeMarkdown from 'remove-markdown';
|
2019-09-16 20:50:51 +00:00
|
|
|
import { shortnameToUnicode } from 'emoji-toolkit';
|
2019-05-20 20:43:50 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
|
|
|
import DisclosureIndicator from '../DisclosureIndicator';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const RepliedThread = React.memo(({
|
2019-09-16 20:26:32 +00:00
|
|
|
tmid, tmsg, isHeader, isTemp, fetchThreadName, id
|
2019-05-20 20:43:50 +00:00
|
|
|
}) => {
|
|
|
|
if (!tmid || !isHeader || isTemp) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tmsg) {
|
2019-09-16 20:26:32 +00:00
|
|
|
fetchThreadName(tmid, id);
|
2019-05-20 20:43:50 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-09-16 20:50:51 +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 }`}>
|
|
|
|
<CustomIcon name='thread' size={20} style={styles.repliedThreadIcon} />
|
|
|
|
<Text style={styles.repliedThreadName} numberOfLines={1}>{msg}</Text>
|
|
|
|
<DisclosureIndicator />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}, (prevProps, nextProps) => {
|
|
|
|
if (prevProps.tmid !== nextProps.tmid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.tmsg !== nextProps.tmsg) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.isHeader !== nextProps.isHeader) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (prevProps.isTemp !== nextProps.isTemp) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
RepliedThread.propTypes = {
|
|
|
|
tmid: PropTypes.string,
|
|
|
|
tmsg: PropTypes.string,
|
2019-09-16 20:26:32 +00:00
|
|
|
id: PropTypes.string,
|
2019-05-20 20:43:50 +00:00
|
|
|
isHeader: PropTypes.bool,
|
|
|
|
isTemp: PropTypes.bool,
|
|
|
|
fetchThreadName: PropTypes.func
|
|
|
|
};
|
|
|
|
RepliedThread.displayName = 'MessageRepliedThread';
|
|
|
|
|
|
|
|
export default RepliedThread;
|