import React from 'react'; import { useTranslation } from 'react-i18next'; import clsx from 'clsx'; import { Row, Col } from 'reactstrap'; import { Link } from 'react-router-dom'; import { TimelinePostInfo } from '../data/timeline'; import { useAvatarUrlWithGivenVersion } from '../user/api'; export interface TimelineItemProps { post: TimelinePostInfo; showDeleteButton?: boolean; current?: boolean; toggleMore?: () => void; onDelete?: () => void; onClick?: () => void; avatarVersion?: number; } const TimelineItem: React.FC = (props) => { const { i18n } = useTranslation(); const current = props.current === true; const { toggleMore: toggleDelete } = props; const avatarUrl = useAvatarUrlWithGivenVersion( props.avatarVersion, props.post.author._links.avatar ); const onOpenMore = React.useMemo< React.MouseEventHandler | undefined >(() => { if (toggleDelete == null) { return undefined; } else { return (e) => { toggleDelete(); e.stopPropagation(); }; } }, [toggleDelete]); return (
{current &&
}
{props.post.time.toLocaleString(i18n.languages)} {props.post.author.nickname}
{props.toggleMore != null ? (
) : null}

{(() => { const { content } = props.post; if (content.type === 'text') { return content.text; } else { return ( ); } })()}

{props.showDeleteButton ? (
) : undefined} ); }; export default TimelineItem;