// Copyright 2018 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import type { ItemClickEvent } from './types/ItemClickEvent'; import type { LocalizerType } from '../../../types/Util'; import type { MediaItemType } from '../../../types/MediaItem'; import { DocumentListItem } from './DocumentListItem'; import { MediaGridItem } from './MediaGridItem'; import { getMessageTimestamp } from '../../../util/getMessageTimestamp'; import { missingCaseError } from '../../../util/missingCaseError'; export type Props = { header?: string; i18n: LocalizerType; mediaItems: ReadonlyArray; onItemClick: (event: ItemClickEvent) => unknown; type: 'media' | 'documents'; }; export function AttachmentSection({ i18n, header, type, mediaItems, onItemClick, }: Props): JSX.Element { return (

{header}

{mediaItems.map((mediaItem, position, array) => { const shouldShowSeparator = position < array.length - 1; const { message, index, attachment } = mediaItem; const onClick = () => { onItemClick({ type, message, attachment, index: mediaItem.index }); }; switch (type) { case 'media': return ( ); case 'documents': return ( ); default: return missingCaseError(type); } })}
); }