/* eslint-disable react/no-danger */ import { useEffect, useState } from 'react'; import { Highlight } from 'react-highlighter-ts'; import he from 'he'; import cn from 'classnames'; import { Button, Dropdown, Menu } from 'antd'; import { DeleteOutlined, EllipsisOutlined, StopOutlined } from '@ant-design/icons'; import s from './ChatUserMessage.module.scss'; import { formatTimestamp } from './messageFmt'; import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ModIcon } from '../../ui'; interface Props { message: ChatMessage; showModeratorMenu: boolean; highlightString: string; sentBySelf: boolean; sameUserAsLast: boolean; } export default function ChatUserMessage({ message, highlightString, showModeratorMenu, sentBySelf, // Move the border to the right and render a background sameUserAsLast, }: Props) { const { body, user, timestamp } = message; const { displayName, displayColor } = user; const color = `var(--theme-user-colors-${displayColor})`; const formattedTimestamp = `Sent at ${formatTimestamp(timestamp)}`; const [formattedMessage, setFormattedMessage] = useState(body); useEffect(() => { setFormattedMessage(he.decode(body)); }, [message]); return (
{!sameUserAsLast && (
{showModeratorMenu && } {displayName}
)}
{formattedMessage}
{showModeratorMenu && }
); } function ModeratorMenu() { const menu = ( Hide message
), key: 0, }, { label: (
Ban User
), key: 1, }, ]} /> ); return (
); }