diff --git a/app/containers/markdown/Emoji.tsx b/app/containers/markdown/Emoji.tsx
index f9e62d10bf..fec3247bf2 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';
@@ -23,13 +23,10 @@ const Emoji = React.memo(({ literal, isMessageContainsOnlyEmoji, getCustomEmoji,
if (emoji && customEmojis) {
return ;
}
-
return (
-
-
- {emojiUnicode}
-
-
+
+ {emojiUnicode}
+
);
});
diff --git a/app/containers/markdown/index.tsx b/app/containers/markdown/index.tsx
index 9300d80f25..5e0545531b 100644
--- a/app/containers/markdown/index.tsx
+++ b/app/containers/markdown/index.tsx
@@ -67,8 +67,20 @@ const isOnlyEmoji = (str: string) => {
return !removeAllEmoji(str).length;
};
+const removeOneEmoji = (str: string) => str.replace(new RegExp(emojiRanges), '');
+
const emojiCount = (str: string) => {
- const counter = removeSpaces(str).length;
+ 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;
};
@@ -131,7 +143,7 @@ class Markdown extends PureComponent {
const { numberOfLines } = this.props;
const defaultStyle = [this.isMessageContainsOnlyEmoji ? styles.textBig : {}, ...context.map(type => styles[type])];
- if (this.isMessageContainsOnlyEmoji) return this.renderEmoji({ literal: removeSpaces(literal) });
+ if (this.isMessageContainsOnlyEmoji) return this.renderEmoji({ literal });
return (
@@ -337,7 +349,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;
}
}