diff --git a/web/chat/message-preview.react.js b/web/chat/message-preview.react.js
index 5b732d25a..dc194c9ba 100644
--- a/web/chat/message-preview.react.js
+++ b/web/chat/message-preview.react.js
@@ -1,71 +1,79 @@
// @flow
import classNames from 'classnames';
import * as React from 'react';
import { getMessageTitle } from 'lib/shared/message-utils';
import { threadIsGroupChat } from 'lib/shared/thread-utils';
import { stringForUser } from 'lib/shared/user-utils';
import {
type MessageInfo,
messageTypes,
type ComposableMessageInfo,
type RobotextMessageInfo,
} from 'lib/types/message-types';
import { type ThreadInfo } from 'lib/types/thread-types';
import { getDefaultTextMessageRules } from '../markdown/rules.react';
import css from './chat-thread-list.css';
type Props = {
+messageInfo: ?MessageInfo,
+threadInfo: ThreadInfo,
};
function MessagePreview(props: Props): React.Node {
- if (!props.messageInfo) {
+ const {
+ messageInfo: originalMessageInfo,
+ threadInfo,
+ threadInfo: {
+ currentUser: { unread },
+ },
+ } = props;
+
+ if (!originalMessageInfo) {
return (
No messages
);
}
const messageInfo: ComposableMessageInfo | RobotextMessageInfo =
- props.messageInfo.type === messageTypes.SIDEBAR_SOURCE
- ? props.messageInfo.sourceMessage
- : props.messageInfo;
- const unread = props.threadInfo.currentUser.unread;
+ originalMessageInfo.type === messageTypes.SIDEBAR_SOURCE
+ ? originalMessageInfo.sourceMessage
+ : originalMessageInfo;
+
const messageTitle = getMessageTitle(
messageInfo,
- props.threadInfo,
+ threadInfo,
getDefaultTextMessageRules().simpleMarkdownRules,
);
if (messageInfo.type === messageTypes.TEXT) {
let usernameText = null;
if (
- threadIsGroupChat(props.threadInfo) ||
- props.threadInfo.name !== '' ||
+ threadIsGroupChat(threadInfo) ||
+ threadInfo.name !== '' ||
messageInfo.creator.isViewer
) {
const userString = stringForUser(messageInfo.creator);
const username = `${userString}: `;
const usernameStyle = unread ? css.white : css.light;
usernameText = {username};
}
const colorStyle = unread ? css.white : css.light;
return (
{usernameText}
{messageTitle}
);
} else {
const colorStyle = unread ? css.white : css.light;
return (
{messageTitle}
);
}
}
export default MessagePreview;