forked from Ivasoft/mattermost-mobile
Fix soft crash for edge emoji formatting (#4705)
This commit is contained in:
@@ -38,6 +38,7 @@ export default class MarkdownEmoji extends PureComponent {
|
||||
editedIndicator: this.renderEditedIndicator,
|
||||
emoji: this.renderEmoji,
|
||||
paragraph: this.renderParagraph,
|
||||
document: this.renderParagraph,
|
||||
text: this.renderText,
|
||||
},
|
||||
});
|
||||
@@ -66,7 +67,7 @@ export default class MarkdownEmoji extends PureComponent {
|
||||
renderParagraph = ({children}) => {
|
||||
const style = getStyleSheet(this.props.theme);
|
||||
return (
|
||||
<View style={style.block}>{children}</View>
|
||||
<View style={style.block}><Text>{children}</Text></View>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ export function hasEmojisOnly(message, customEmojis) {
|
||||
return {isEmojiOnly: false, shouldRenderJumboEmoji: false};
|
||||
}
|
||||
|
||||
const chunks = message.trim().split(' ').filter((m) => m && m.length > 0);
|
||||
const chunks = message.trim().replace(/\n/g, ' ').split(' ').filter((m) => m && m.length > 0);
|
||||
|
||||
if (chunks.length === 0) {
|
||||
return {isEmojiOnly: false, shouldRenderJumboEmoji: false};
|
||||
|
||||
@@ -64,6 +64,19 @@ describe('hasEmojisOnly with named emojis', () => {
|
||||
name: 'This should render a codeblock instead',
|
||||
message: ' :D',
|
||||
expected: {isEmojiOnly: false, shouldRenderJumboEmoji: false},
|
||||
}, {
|
||||
name: 'Mixed emojis with whitespace and newlines',
|
||||
message: `:fire:
|
||||
:-)`,
|
||||
expected: {isEmojiOnly: true, shouldRenderJumboEmoji: true},
|
||||
}, {
|
||||
name: 'Emojis with whitespace and newlines',
|
||||
message: ':fire: \n:smile:',
|
||||
expected: {isEmojiOnly: true, shouldRenderJumboEmoji: true},
|
||||
}, {
|
||||
name: 'Emojis with newlines',
|
||||
message: ':fire:\n:smile:',
|
||||
expected: {isEmojiOnly: true, shouldRenderJumboEmoji: true},
|
||||
}];
|
||||
|
||||
const customEmojis = new Map([['valid_custom', 0]]);
|
||||
|
||||
Reference in New Issue
Block a user