import { Download } from "lucide-react"; import { postNoBody } from "../../../api"; import { useI18n } from "../../../i18n"; import type { Attachment, Post } from "../../../types/post"; import { fileIcon } from "../utils/fileIcon"; import { formatBytes } from "../utils/formatBytes"; import { postDisplayText } from "../utils/postText"; function AttachmentRow({ postId, att }: { postId: string; att: Attachment }) { const isImageAsDoc = att.mime.startsWith("image/"); const { Icon, color } = fileIcon({ mime: att.mime, filename: att.filename }); return ( { void postNoBody(`/api/posts/${postId}/attachments/${att.id}/download`); }} >
{isImageAsDoc && att.thumbnailUrl ? ( <>
) : (
)}
{att.filename}
{formatBytes(att.sizeBytes)}
); } export function FileDocBubble({ post }: { post: Post }) { const { lang } = useI18n(); const text = postDisplayText(post, lang); return (
{post.attachments.map((att) => ( ))} {text ? (
{text}
) : null}
); }