import React from 'react'; import { isImageTypeSupported, isVideoTypeSupported, } from '../../../util/GoogleChrome'; import { Message } from './types/Message'; import { Localizer } from '../../../types/Util'; interface Props { message: Message; onClick?: () => void; i18n: Localizer; } export class MediaGridItem extends React.Component { public renderContent() { const { message, i18n } = this.props; const { attachments } = message; if (!message.thumbnailObjectUrl) { return null; } if (!attachments || !attachments.length) { return null; } const first = attachments[0]; const { contentType } = first; if (contentType && isImageTypeSupported(contentType)) { return ( {i18n('lightboxImageAlt')} ); } else if (contentType && isVideoTypeSupported(contentType)) { return (
{i18n('lightboxImageAlt')}
); } return null; } public render() { return (
{this.renderContent()}
); } }