VideoModal: convert to TSX

This commit is contained in:
Alex Gleason 2022-04-24 18:07:20 -05:00
parent e648162f66
commit b8eff3e46b
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,51 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { useHistory } from 'react-router-dom';
import Video from 'soapbox/features/video';
import type { Status, Account, Attachment } from 'soapbox/types/entities';
interface IVideoModal {
media: Attachment,
status: Status,
account: Account,
time: number,
onClose: () => void,
}
const VideoModal: React.FC<IVideoModal> = ({ status, account, media, time, onClose }) => {
const history = useHistory();
const handleStatusClick: React.MouseEventHandler = e => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
history.push(`/@${account.acct}/posts/${status.id}`);
}
};
const link = status && account && (
<a href={status.url} onClick={handleStatusClick}>
<FormattedMessage id='lightbox.view_context' defaultMessage='View context' />
</a>
);
return (
<div className='modal-root__modal video-modal'>
<div>
<Video
preview={media.preview_url}
blurhash={media.blurhash}
src={media.url}
startTime={time}
onCloseVideo={onClose}
link={link}
detailed
alt={media.description}
/>
</div>
</div>
);
};
export default VideoModal;