import { List as ImmutableList } from 'immutable'; import React from 'react'; import { FormattedList, FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { openModal } from 'soapbox/actions/modals'; import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper'; import { useAppDispatch } from 'soapbox/hooks'; import type { Status } from 'soapbox/types/entities'; interface IStatusReplyMentions { status: Status, } const StatusReplyMentions: React.FC = ({ status }) => { const dispatch = useAppDispatch(); const handleOpenMentionsModal: React.MouseEventHandler = (e) => { e.stopPropagation(); dispatch(openModal('MENTIONS', { username: status.getIn(['account', 'acct']), statusId: status.get('id'), })); }; if (!status.get('in_reply_to_id')) { return null; } const to = status.get('mentions', ImmutableList()); // The post is a reply, but it has no mentions. // Rare, but it can happen. if (to.size === 0) { return (
); } // The typical case with a reply-to and a list of mentions. const accounts = to.slice(0, 2).map(account => ( @{account.get('username')} )).toArray(); if (to.size > 2) { accounts.push( , ); } return (
, }} />
); }; export default StatusReplyMentions;