diff --git a/web/chat/text-message.react.js b/web/chat/text-message.react.js index 6bf3ab7b6..33523edbb 100644 --- a/web/chat/text-message.react.js +++ b/web/chat/text-message.react.js @@ -1,80 +1,83 @@ // @flow import classNames from 'classnames'; import invariant from 'invariant'; import * as React from 'react'; import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors'; import { onlyEmojiRegex } from 'lib/shared/emojis'; -import { colorIsDark } from 'lib/shared/thread-utils'; +import { colorIsDark, threadHasPermission } from 'lib/shared/thread-utils'; import { messageTypes } from 'lib/types/message-types'; -import type { ThreadInfo } from 'lib/types/thread-types'; +import { type ThreadInfo, threadPermissions } from 'lib/types/thread-types'; import Markdown from '../markdown/markdown.react'; import css from './chat-message-list.css'; import ComposedMessage from './composed-message.react'; import { MessageListContext } from './message-list-types'; import type { MessagePositionInfo, OnMessagePositionInfo, } from './message-position-types'; import textMessageSendFailed from './text-message-send-failed'; type Props = {| +item: ChatMessageInfoItem, +threadInfo: ThreadInfo, +setMouseOverMessagePosition: ( messagePositionInfo: MessagePositionInfo, ) => void, +mouseOverMessagePosition: ?OnMessagePositionInfo, |}; function TextMessage(props: Props) { invariant( props.item.messageInfo.type === messageTypes.TEXT, 'TextMessage should only be used for messageTypes.TEXT', ); const { text, creator: { isViewer }, } = props.item.messageInfo; const messageStyle = {}; let darkColor = false; if (isViewer) { const threadColor = props.threadInfo.color; darkColor = colorIsDark(threadColor); messageStyle.backgroundColor = `#${threadColor}`; } else { messageStyle.backgroundColor = 'rgba(221,221,221,0.73)'; } const onlyEmoji = onlyEmojiRegex.test(text); const messageClassName = classNames({ [css.textMessage]: true, [css.normalTextMessage]: !onlyEmoji, [css.emojiOnlyTextMessage]: onlyEmoji, [css.darkTextMessage]: darkColor, [css.lightTextMessage]: !darkColor, }); const messageListContext = React.useContext(MessageListContext); invariant(messageListContext, 'DummyTextNode should have MessageListContext'); const rules = messageListContext.getTextMessageMarkdownRules(darkColor); - + const canReply = threadHasPermission( + props.threadInfo, + threadPermissions.VOICED, + ); return (
{text}
); } export default TextMessage;