2020-05-04 14:09:47 +00:00
|
|
|
import React from 'react';
|
2019-05-20 20:43:50 +00:00
|
|
|
import { Text } from 'react-native';
|
|
|
|
|
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';
|
|
|
|
|
2021-07-21 21:01:59 +00:00
|
|
|
interface IMessageEmoji {
|
|
|
|
content: any;
|
|
|
|
baseUrl: string;
|
|
|
|
standardEmojiStyle: object;
|
|
|
|
customEmojiStyle: object;
|
|
|
|
getCustomEmoji: Function;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Emoji = React.memo(({ content, baseUrl, standardEmojiStyle, customEmojiStyle, getCustomEmoji }: IMessageEmoji) => {
|
2019-05-20 20:43:50 +00:00
|
|
|
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.displayName = 'MessageEmoji';
|
|
|
|
|
|
|
|
export default Emoji;
|