import { FC, MouseEvent } from 'react'; import { FaArrowRight, FaTimes } from 'react-icons/fa'; import { formatMentionTime, IMentionEntry, LocalizeText, MentionType } from '../../api'; import { LayoutAvatarImageView } from '../../common'; import { MentionMessageView } from './MentionMessageView'; interface MentionRowViewProps { mention: IMentionEntry; ownUsername: string; onOpen: (mention: IMentionEntry) => void; onGoto?: (mention: IMentionEntry) => void; onRemove?: (mention: IMentionEntry) => void; } export const MentionRowView: FC = props => { const { mention, ownUsername, onOpen, onGoto = null, onRemove = null } = props; const isRoom = (mention.mentionType === MentionType.ROOM); const typeTitle = LocalizeText(isRoom ? 'mentions.type.room' : 'mentions.type.direct'); const time = formatMentionTime(mention.timestamp); const stop = (event: MouseEvent, action: () => void) => { event.stopPropagation(); action(); }; return (
onOpen(mention) }> { !mention.read && }
{ isRoom ? '∗' : '@' }
{ mention.senderUsername } { (mention.roomName && (mention.roomName.length > 0)) && · { mention.roomName } }
{ (time.length > 0) && { time } }
{ onGoto && } { onRemove && }
); };