import React from "react"; import clsx from "clsx"; import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Modal, Button } from "react-bootstrap"; import { useAvatar } from "@/services/user"; import { TimelinePostInfo } from "@/services/timeline"; import BlobImage from "../common/BlobImage"; const TimelinePostDeleteConfirmDialog: React.FC<{ onClose: () => void; onConfirm: () => void; }> = ({ onClose, onConfirm }) => { const { t } = useTranslation(); return ( {t("timeline.post.deleteDialog.title")} {t("timeline.post.deleteDialog.prompt")} ); }; export interface TimelineItemProps { post: TimelinePostInfo; current?: boolean; more?: { isOpen: boolean; toggle: () => void; onDelete: () => void; }; onClick?: () => void; onResize?: () => void; className?: string; style?: React.CSSProperties; } const TimelineItem: React.FC = (props) => { const { i18n } = useTranslation(); const current = props.current === true; const { more, onResize } = props; const avatar = useAvatar(props.post.author.username); const [deleteDialog, setDeleteDialog] = React.useState(false); return (
{current &&
}
{props.post.time.toLocaleString(i18n.languages)} {props.post.author.nickname} {more != null ? ( { more.toggle(); e.stopPropagation(); }} /> ) : null}
{(() => { const { content } = props.post; if (content.type === "text") { return content.text; } else { return ( ); } })()}
{more != null && more.isOpen ? (
{ setDeleteDialog(true); e.stopPropagation(); }} />
) : null}
{deleteDialog && more != null ? ( { setDeleteDialog(false); more.toggle(); }} onConfirm={more.onDelete} /> ) : null}
); }; export default TimelineItem;