Skip to content

Commit 3a0a827

Browse files
committed
Fix - Some emojis sent are not shown in conversation
1 parent 3c1d3c5 commit 3a0a827

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
@@ -3489,10 +3489,6 @@ const CONST = {
34893489
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,
34903490
// eslint-disable-next-line max-len, no-misleading-character-class
34913491
EMOJI_SKIN_TONES: /[\u{1f3fb}-\u{1f3ff}]/gu,
3492-
/** Regex to match emojis that are not wrapped in `<emoji>` tags */
3493-
get UNWRAPPED_EMOJI() {
3494-
return new RegExp(`(?:(?!<emoji[^>]*>))(${this.EMOJIS.source})(?:(?!</emoji[^>]*>))`, 'gu');
3495-
},
34963492

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

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)