diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js --- a/lib/shared/message-utils.js +++ b/lib/shared/message-utils.js @@ -495,9 +495,14 @@ }; } +type MessagePreviewPart = { + +text: string, + // unread has highest contrast, followed by primary, followed by secondary + +style: 'unread' | 'primary' | 'secondary', +}; type MessagePreviewResult = { - +message: string, - +username: ?string, + +message: MessagePreviewPart, + +username: ?MessagePreviewPart, }; function getMessagePreview( originalMessageInfo: MessageInfo, @@ -512,19 +517,33 @@ ? originalMessageInfo.sourceMessage : originalMessageInfo; - const messageTitle = getMessageTitle(messageInfo, threadInfo, markdownRules); - const hasUsername = threadIsGroupChat(threadInfo) || threadInfo.name !== '' || messageInfo.creator.isViewer; - let userString = null; + let username = null; if (messageInfo.type === messageTypes.TEXT && hasUsername) { - userString = stringForUser(messageInfo.creator); + username = { + text: stringForUser(messageInfo.creator), + style: 'secondary', + }; + } + + const messageTitle = getMessageTitle(messageInfo, threadInfo, markdownRules); + const message = { + text: messageTitle, + style: messageInfo.type === messageTypes.TEXT ? 'primary' : 'secondary', + }; + + if (threadInfo.currentUser.unread) { + message.style = 'unread'; + if (username) { + username.style = 'unread'; + } } - return { message: messageTitle, username: userString }; + return { message, username }; } export { 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 @@ -23,7 +23,6 @@ }, } = props; - const colorStyle = unread ? css.unread : css.read; if (!originalMessageInfo) { return (