From 30d3b0b9f973eabcfc933b0e225749bc1ff7d495 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 6 Jul 2022 17:01:33 -0300 Subject: [PATCH] [FIX] Markdown not rendering emojis correctly on server version 5.0.0 (#4343) --- app/containers/markdown/new/BigEmoji.tsx | 2 +- app/containers/markdown/new/Emoji.tsx | 19 ++++++++++++++----- app/containers/markdown/new/Inline.tsx | 2 +- package.json | 2 +- yarn.lock | 8 ++++---- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/containers/markdown/new/BigEmoji.tsx b/app/containers/markdown/new/BigEmoji.tsx index f8032ff8f..552050532 100644 --- a/app/containers/markdown/new/BigEmoji.tsx +++ b/app/containers/markdown/new/BigEmoji.tsx @@ -17,7 +17,7 @@ const styles = StyleSheet.create({ const BigEmoji = ({ value }: IBigEmojiProps) => ( {value.map(block => ( - + ))} ); diff --git a/app/containers/markdown/new/Emoji.tsx b/app/containers/markdown/new/Emoji.tsx index a7d1810ae..8ed5ef8c0 100644 --- a/app/containers/markdown/new/Emoji.tsx +++ b/app/containers/markdown/new/Emoji.tsx @@ -10,20 +10,29 @@ import CustomEmoji from '../../EmojiPicker/CustomEmoji'; import MarkdownContext from './MarkdownContext'; interface IEmojiProps { - value: EmojiProps['value']; + block: EmojiProps; isBigEmoji?: boolean; } -const Emoji = ({ value, isBigEmoji }: IEmojiProps) => { +const Emoji = ({ block, isBigEmoji }: IEmojiProps) => { const { theme } = useTheme(); const { baseUrl, getCustomEmoji } = useContext(MarkdownContext); - const emojiUnicode = shortnameToUnicode(`:${value.value}:`); - const emoji = getCustomEmoji?.(value.value); + + if ('unicode' in block) { + return {block.unicode}; + } + const emojiToken = block?.shortCode ? `:${block.shortCode}:` : `:${block.value?.value}:`; + const emojiUnicode = shortnameToUnicode(emojiToken); + const emoji = getCustomEmoji?.(block.value?.value); if (emoji) { return ; } - return {emojiUnicode}; + return ( + + {emojiUnicode} + + ); }; export default Emoji; diff --git a/app/containers/markdown/new/Inline.tsx b/app/containers/markdown/new/Inline.tsx index 70dca0846..c9ad9211b 100644 --- a/app/containers/markdown/new/Inline.tsx +++ b/app/containers/markdown/new/Inline.tsx @@ -48,7 +48,7 @@ const Inline = ({ value }: IParagraphProps) => { /> ); case 'EMOJI': - return ; + return ; case 'MENTION_CHANNEL': return ; case 'INLINE_CODE': diff --git a/package.json b/package.json index ecbec904a..ef766f4b6 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@react-navigation/elements": "^1.3.3", "@react-navigation/native": "6.0.10", "@react-navigation/stack": "6.2.1", - "@rocket.chat/message-parser": "0.30.0", + "@rocket.chat/message-parser": "^0.31.14", "@rocket.chat/sdk": "RocketChat/Rocket.Chat.js.SDK#mobile", "@rocket.chat/ui-kit": "^0.31.13", "bytebuffer": "^5.0.1", diff --git a/yarn.lock b/yarn.lock index 7bd9a2c85..484f38cdb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4140,10 +4140,10 @@ dependencies: eslint-plugin-import "^2.17.2" -"@rocket.chat/message-parser@0.30.0": - version "0.30.0" - resolved "https://registry.yarnpkg.com/@rocket.chat/message-parser/-/message-parser-0.30.0.tgz#63a25aa7fa17724d55db80f95f7f8d6a99ae42ff" - integrity sha512-pI7ajaojv+GqhQBMnFiBOWerE7zIlJywWFaLzJlIC/wsJ9LgX6YaKY2wqc909nkr+E4qZY1luJ61ErXGGSF9Zw== +"@rocket.chat/message-parser@^0.31.14": + version "0.31.14" + resolved "https://registry.yarnpkg.com/@rocket.chat/message-parser/-/message-parser-0.31.14.tgz#55042be10a7cd49a7a9a969272bc38897fe1c252" + integrity sha512-WgaWLMCFWcmhRb7cEm1Q8GoD8lgpPuTniG27Qmfw8k86MuZfdHj+cdOfhvkmdNORxx181RhfksTO0k6IkRxh6A== "@rocket.chat/sdk@RocketChat/Rocket.Chat.js.SDK#mobile": version "1.3.0-mobile"