diff --git a/web/src/components/MemoView/components/metadata/AttachmentCard.tsx b/web/src/components/MemoView/components/metadata/AttachmentCard.tsx index 2aadfb76..c5ce9dc9 100644 --- a/web/src/components/MemoView/components/metadata/AttachmentCard.tsx +++ b/web/src/components/MemoView/components/metadata/AttachmentCard.tsx @@ -28,6 +28,10 @@ const AttachmentCard = ({ attachment, onClick, className }: AttachmentCardProps) return ; } + if (attachmentType === "audio/*") { + return ; + } + return null; }; diff --git a/web/src/components/MemoView/components/metadata/AttachmentList.tsx b/web/src/components/MemoView/components/metadata/AttachmentList.tsx index ce18cea3..4f48224f 100644 --- a/web/src/components/MemoView/components/metadata/AttachmentList.tsx +++ b/web/src/components/MemoView/components/metadata/AttachmentList.tsx @@ -1,4 +1,4 @@ -import { FileIcon, PaperclipIcon } from "lucide-react"; +import { FileAudioIcon, FileIcon, PaperclipIcon } from "lucide-react"; import { useMemo, useState } from "react"; import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb"; import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment"; @@ -11,25 +11,26 @@ interface AttachmentListProps { attachments: Attachment[]; } -// Type guards for attachment types const isImageAttachment = (attachment: Attachment): boolean => getAttachmentType(attachment) === "image/*"; const isVideoAttachment = (attachment: Attachment): boolean => getAttachmentType(attachment) === "video/*"; -const isMediaAttachment = (attachment: Attachment): boolean => isImageAttachment(attachment) || isVideoAttachment(attachment); +const isAudioAttachment = (attachment: Attachment): boolean => getAttachmentType(attachment) === "audio/*"; -// Separate attachments into media (images/videos) and documents -const separateMediaAndDocs = (attachments: Attachment[]): { media: Attachment[]; docs: Attachment[] } => { - const media: Attachment[] = []; +const separateAttachments = (attachments: Attachment[]) => { + const visual: Attachment[] = []; + const audio: Attachment[] = []; const docs: Attachment[] = []; for (const attachment of attachments) { - if (isMediaAttachment(attachment)) { - media.push(attachment); + if (isImageAttachment(attachment) || isVideoAttachment(attachment)) { + visual.push(attachment); + } else if (isAudioAttachment(attachment)) { + audio.push(attachment); } else { docs.push(attachment); } } - return { media, docs }; + return { visual, audio, docs }; }; const DocumentItem = ({ attachment }: { attachment: Attachment }) => { @@ -60,16 +61,30 @@ const DocumentItem = ({ attachment }: { attachment: Attachment }) => { ); }; -interface MediaItemProps { +const AudioItem = ({ attachment }: { attachment: Attachment }) => { + const sourceUrl = getAttachmentUrl(attachment); + + return ( +