import { ArrowDownToLine, LoaderCircle } from "lucide-react"; import { useState } from "react"; import { useI18n } from "../../../i18n"; import type { Attachment, Post } from "../../../types/post"; import { downloadAttachment } from "../utils/downloadFile"; import { fileIcon } from "../utils/fileIcon"; import { filenameWithExtension, middleEllipsisFilename, } from "../utils/filenameDisplay"; import { formatBytes } from "../utils/formatBytes"; import { postDisplayText } from "../utils/postText"; function AttachmentRow({ postId, att }: { postId: string; att: Attachment }) { const { t } = useI18n(); const isImageAsDoc = att.mime.startsWith("image/"); const { Icon, color } = fileIcon({ mime: att.mime, filename: att.filename }); const displayFilename = filenameWithExtension(att.filename, att.mime); const [isDownloading, setIsDownloading] = useState(false); const handleDownload = () => { if (isDownloading) return; setIsDownloading(true); void downloadAttachment(postId, att.id, displayFilename) .finally(() => setIsDownloading(false)) .catch(() => {}); }; return (