import { useEffect, useRef, useState } from 'react'; import MessageInput from './MessageInput'; import Avatar from './Avatar'; import { UserLink } from './UserInfo'; import Button from './Button'; import { format, embedUrls } from '../utils/embed'; import { chatItemStyle } from './helpers/BubbleStyle'; import { useVisitor } from './VisitorContext'; /** * @param {{ visitor: import('../client').SecureUser, msg: import('../client').Message, draft: string, active: number, setActive: Function, onStartEditing: Function, postComment: function({body:string, attach: string | File}) : void }} props props * @returns import('react').ReactElement */ export default function Comment({ msg, draft, active, setActive, onStartEditing, postComment }) { const [visitor] = useVisitor(); /** @type {import('react').MutableRefObject} */ const embedRef = useRef(null); /** @type {import('react').MutableRefObject} */ const msgRef = useRef(null); const [author] = useState(msg.user); useEffect(() => { if (msgRef.current && embedRef.current) { embedUrls(msgRef.current.querySelectorAll('a'), embedRef.current); if (!embedRef.current.hasChildNodes()) { embedRef.current.style.display = 'none'; } } }, []); return (
{ msg.to && msg.replyto && msg.replyto > 0 && ( ) }
{ msg.body &&

= 0) }} />

} { msg.photo &&
}
{ active === msg.rid && } {visitor.uid > 0 &&
{ visitor.uid > 0 ? ( <> {active === msg.rid || setActive(msg.rid)}>Reply} { visitor.uid == msg.user.uid && <>  ·  onStartEditing(msg)}>Edit } ) : ( <>  · {active === msg.rid || } ) }
}
); } /** * @type {import('react').CSSProperties} */ const linkStyle = { cursor: 'pointer' };