diff --git a/web/chat/message-preview.react.js b/web/chat/message-preview.react.js --- a/web/chat/message-preview.react.js +++ b/web/chat/message-preview.react.js @@ -25,6 +25,7 @@ const { messageInfo: messageInfoProps, threadInfo } = props; const { unread } = threadInfo.currentUser; + let usernameText = null; const colorStyle = unread ? css.white : css.light; if (!messageInfoProps) { @@ -44,30 +45,23 @@ threadInfo, getDefaultTextMessageRules().simpleMarkdownRules, ); - if (messageInfo.type === messageTypes.TEXT) { - let usernameText = null; - if ( - threadIsGroupChat(threadInfo) || - threadInfo.name !== '' || - messageInfo.creator.isViewer - ) { - const userString = stringForUser(messageInfo.creator); - const username = `${userString}: `; - usernameText = {username}; - } - return ( -
- {usernameText} - {messageTitle} -
- ); - } else { - return ( -
- {messageTitle} -
- ); + + const hasUsername = + threadIsGroupChat(threadInfo) || + threadInfo.name !== '' || + messageInfo.creator.isViewer; + + if (messageInfo.type === messageTypes.TEXT && hasUsername) { + const userString = stringForUser(messageInfo.creator); + usernameText = {`${userString}: `}; } + + return ( +
+ {usernameText} + {messageTitle} +
+ ); } export default MessagePreview;