Skip to content

Commit b9c09eb

Browse files
authored
Merge pull request Expensify#67868 from dmkt9/fix/66602-emoji-not-showing
Fix - Some emojis sent are not shown in conversation
2 parents c7c0583 + 57c80cc commit b9c09eb

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/CONST/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,10 +3497,6 @@ const CONST = {
34973497
EMOJIS: /[\p{Extended_Pictographic}\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}](\u200D[\p{Extended_Pictographic}\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]|[\u{1F3FB}-\u{1F3FF}]|[\u{E0020}-\u{E007F}]|\uFE0F|\u20E3)*|[\u{1F1E6}-\u{1F1FF}]{2}|[#*0-9]\uFE0F?\u20E3/du,
34983498
// eslint-disable-next-line max-len, no-misleading-character-class
34993499
EMOJI_SKIN_TONES: /[\u{1f3fb}-\u{1f3ff}]/gu,
3500-
/** Regex to match emojis that are not wrapped in `<emoji>` tags */
3501-
get UNWRAPPED_EMOJI() {
3502-
return new RegExp(`(?:(?!<emoji[^>]*>))(${this.EMOJIS.source})(?:(?!</emoji[^>]*>))`, 'gu');
3503-
},
35043500

35053501
PRIVATE_USER_AREA: /[\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/u,
35063502

src/components/RenderHTML.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useMemo} from 'react';
22
import {RenderHTMLSource} from 'react-native-render-html';
33
import useWindowDimensions from '@hooks/useWindowDimensions';
4-
import CONST from '@src/CONST';
4+
import Parser from '@libs/Parser';
55

66
type RenderHTMLProps = {
77
/** HTML string to render */
@@ -15,8 +15,12 @@ type RenderHTMLProps = {
1515
function RenderHTML({html: htmlParam}: RenderHTMLProps) {
1616
const {windowWidth} = useWindowDimensions();
1717
const html = useMemo(() => {
18-
// Wrap all unwrapped emojis in `<emoji>` tags.
19-
return htmlParam.replace(CONST.REGEX.UNWRAPPED_EMOJI, '<emoji>$1</emoji>');
18+
return (
19+
Parser.replace(htmlParam, {shouldEscapeText: false, filterRules: ['emoji']})
20+
// Remove double <emoji> tag if exists and keep the outermost tag (always the original tag).
21+
.replace(/(<emoji[^>]*>)(?:<emoji[^>]*>)+/g, '$1')
22+
.replace(/(<\/emoji[^>]*>)(?:<\/emoji[^>]*>)+/g, '$1')
23+
);
2024
}, [htmlParam]);
2125
return (
2226
<RenderHTMLSource

0 commit comments

Comments
 (0)