2018-01-30 19:48:26 +00:00
|
|
|
import React from 'react';
|
2019-05-20 20:43:50 +00:00
|
|
|
import { Text } from 'react-native';
|
2018-01-30 19:48:26 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-05-20 20:43:50 +00:00
|
|
|
|
2019-12-11 19:00:38 +00:00
|
|
|
import shortnameToUnicode from '../../utils/shortnameToUnicode';
|
2018-01-30 19:48:26 +00:00
|
|
|
import CustomEmoji from '../EmojiPicker/CustomEmoji';
|
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
const Emoji = React.memo(({
|
|
|
|
content, standardEmojiStyle, customEmojiStyle, baseUrl, getCustomEmoji
|
|
|
|
}) => {
|
|
|
|
const parsedContent = content.replace(/^:|:$/g, '');
|
|
|
|
const emoji = getCustomEmoji(parsedContent);
|
|
|
|
if (emoji) {
|
|
|
|
return <CustomEmoji key={content} baseUrl={baseUrl} style={customEmojiStyle} emoji={emoji} />;
|
2018-09-25 19:28:42 +00:00
|
|
|
}
|
2019-09-16 20:50:51 +00:00
|
|
|
return <Text style={standardEmojiStyle}>{ shortnameToUnicode(content) }</Text>;
|
2019-05-20 20:43:50 +00:00
|
|
|
}, () => true);
|
2018-09-25 19:28:42 +00:00
|
|
|
|
2019-05-20 20:43:50 +00:00
|
|
|
Emoji.propTypes = {
|
|
|
|
content: PropTypes.string,
|
|
|
|
standardEmojiStyle: PropTypes.object,
|
|
|
|
customEmojiStyle: PropTypes.object,
|
|
|
|
baseUrl: PropTypes.string,
|
|
|
|
getCustomEmoji: PropTypes.func
|
|
|
|
};
|
|
|
|
Emoji.displayName = 'MessageEmoji';
|
|
|
|
|
|
|
|
export default Emoji;
|