diff --git a/app/containers/markdown/Emoji.tsx b/app/containers/markdown/Emoji.tsx
index f9e62d10bfc..a372e25c6ed 100644
--- a/app/containers/markdown/Emoji.tsx
+++ b/app/containers/markdown/Emoji.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { View, Text } from 'react-native';
+import { Text } from 'react-native';
import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode';
import CustomEmoji from '../EmojiPicker/CustomEmoji';
@@ -25,11 +25,9 @@ const Emoji = React.memo(({ literal, isMessageContainsOnlyEmoji, getCustomEmoji,
}
return (
-
-
- {emojiUnicode}
-
-
+
+ {emojiUnicode}
+
);
});
diff --git a/app/containers/markdown/index.tsx b/app/containers/markdown/index.tsx
index 9300d80f25c..b00cd0a7004 100644
--- a/app/containers/markdown/index.tsx
+++ b/app/containers/markdown/index.tsx
@@ -67,9 +67,20 @@ const isOnlyEmoji = (str: string) => {
return !removeAllEmoji(str).length;
};
-const emojiCount = (str: string) => {
- const counter = removeSpaces(str).length;
+const removeOneEmoji = (str: string) => str.replace(new RegExp(emojiRanges), '');
+const emojiCount = (str: string) => {
+ str = removeSpaces(str);
+ let oldLength = 0;
+ let counter = 0;
+
+ while (oldLength !== str.length) {
+ oldLength = str.length;
+ str = removeOneEmoji(str);
+ if (oldLength !== str.length) {
+ counter += 1;
+ }
+ }
return counter;
};
@@ -337,7 +348,7 @@ class Markdown extends PureComponent {
m = formatHyperlink(m);
let ast = parser.parse(m);
ast = mergeTextNodes(ast);
- this.isMessageContainsOnlyEmoji = isOnlyEmoji(m) && emojiCount(m) <= 6;
+ this.isMessageContainsOnlyEmoji = isOnlyEmoji(m) && emojiCount(m) <= 3;
return this.renderer?.render(ast) || null;
}
}