bigbuffet-rw/app/soapbox/features/ui/components/video_modal.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
2020-03-27 13:59:38 -07:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { FormattedMessage } from 'react-intl';
2022-03-17 18:17:28 -07:00
import { withRouter } from 'react-router-dom';
2022-01-10 14:01:24 -08:00
import Video from 'soapbox/features/video';
2020-03-27 13:59:38 -07:00
2022-03-17 18:17:28 -07:00
export default @withRouter
class VideoModal extends ImmutablePureComponent {
2020-03-27 13:59:38 -07:00
static propTypes = {
media: ImmutablePropTypes.map.isRequired,
2022-03-23 10:14:42 -07:00
status: ImmutablePropTypes.record,
account: ImmutablePropTypes.record,
2020-03-27 13:59:38 -07:00
time: PropTypes.number,
onClose: PropTypes.func.isRequired,
2022-03-17 18:17:28 -07:00
history: PropTypes.object,
2020-03-27 13:59:38 -07:00
};
handleStatusClick = e => {
const { status, account } = this.props;
2020-03-27 13:59:38 -07:00
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
2022-03-17 18:17:28 -07:00
this.props.history.push(`/@${account.get('acct')}/posts/${status.get('id')}`);
2020-03-27 13:59:38 -07:00
}
}
render() {
const { media, status, account, time, onClose } = this.props;
2020-03-27 13:59:38 -07:00
const link = status && account && <a href={status.get('url')} onClick={this.handleStatusClick}><FormattedMessage id='lightbox.view_context' defaultMessage='View context' /></a>;
2020-03-27 13:59:38 -07:00
return (
<div className='modal-root__modal video-modal'>
<div>
<Video
preview={media.get('preview_url')}
blurhash={media.get('blurhash')}
src={media.get('url')}
startTime={time}
onCloseVideo={onClose}
link={link}
detailed
alt={media.get('description')}
/>
</div>
</div>
);
}
}