import React, { memo, useMemo } from '../../../lib/teact/teact'; import type { FC } from '../../../lib/teact/teact'; import type { ApiAttachment } from '../../../api/types'; import { SUPPORTED_IMAGE_CONTENT_TYPES, SUPPORTED_VIDEO_CONTENT_TYPES } from '../../../config'; import { getFileExtension } from '../../common/helpers/documentInfo'; import buildClassName from '../../../util/buildClassName'; import { formatMediaDuration } from '../../../util/dateFormat'; import File from '../../common/File'; import styles from './AttachmentModalItem.module.scss'; type OwnProps = { attachment: ApiAttachment; className?: string; shouldDisplayCompressed?: boolean; shouldDisplayGrouped?: boolean; isSingle?: boolean; index: number; onDelete?: (index: number) => void; }; const AttachmentModalItem: FC = ({ attachment, className, isSingle, shouldDisplayCompressed, shouldDisplayGrouped, index, onDelete, }) => { const displayType = getDisplayType(attachment, shouldDisplayCompressed); const content = useMemo(() => { switch (displayType) { case 'image': return ( ); case 'video': return ( <> {Boolean(attachment.quick?.duration) && (
{formatMediaDuration(attachment.quick!.duration)}
)}