MM-28450 Fix crash when posting at-mention that does not belong to the channel (#4778) (#4782)

(cherry picked from commit 05f264554e)

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build 2020-09-08 17:02:25 -04:00 committed by GitHub
parent c11b92b64e
commit 9ecc755c65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,9 +141,9 @@ export default class AtMention extends React.PureComponent {
render() {
const {isSearchResult, mentionName, mentionStyle, onPostPress, teammateNameDisplay, textStyle, mentionKeys} = this.props;
const {user} = this.state;
const {backgroundColor, ...styleText} = StyleSheet.flatten(textStyle);
const mentionTextStyle = [];
let backgroundColor;
let canPress = false;
let highlighted;
let isMention = false;
@ -152,6 +152,13 @@ export default class AtMention extends React.PureComponent {
let onPress;
let suffix;
let suffixElement;
let styleText;
if (textStyle) {
const {backgroundColor: bg, ...otherStyles} = StyleSheet.flatten(textStyle);
backgroundColor = bg;
styleText = otherStyles;
}
if (user?.username) {
suffix = this.props.mentionName.substring(user.username.length);