The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/Message/Attachments/Item.tsx

24 lines
854 B

import React, { FC, memo } from 'react';
import { AttachmentProps } from './AttachmentProps';
import DefaultAttachment from './DefaultAttachment';
import { FileProp } from './FileProp';
import { isFileAttachment, FileAttachment } from './Files';
import { QuoteAttachment, QuoteAttachmentProps } from './QuoteAttachment';
const isQuoteAttachment = (attachment: AttachmentProps): attachment is QuoteAttachmentProps =>
'message_link' in attachment && attachment.message_link !== null;
const Item: FC<{ attachment: AttachmentProps; file?: FileProp }> = ({ attachment, file }) => {
if (isFileAttachment(attachment)) {
return <FileAttachment {...attachment} file={file} />;
}
if (isQuoteAttachment(attachment)) {
return <QuoteAttachment {...attachment} />;
}
return <DefaultAttachment {...(attachment as any)} />;
};
export default memo(Item);