2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2017-04-13 09:04:18 -04:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-21 14:05:35 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2017-12-04 02:26:40 -05:00
|
|
|
import Video from 'flavours/glitch/features/video';
|
2017-05-02 20:04:16 -04:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2019-05-03 10:16:30 -04:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-10-02 21:34:58 -04:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import Icon from 'mastodon/components/icon';
|
2017-04-13 09:04:18 -04:00
|
|
|
|
2017-06-23 13:36:54 -04:00
|
|
|
export default class VideoModal extends ImmutablePureComponent {
|
2017-04-13 09:04:18 -04:00
|
|
|
|
2019-05-03 10:16:30 -04:00
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2017-05-12 08:44:10 -04:00
|
|
|
static propTypes = {
|
|
|
|
media: ImmutablePropTypes.map.isRequired,
|
2019-05-03 10:16:30 -04:00
|
|
|
status: ImmutablePropTypes.map,
|
2017-05-12 08:44:10 -04:00
|
|
|
time: PropTypes.number,
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2019-05-03 10:16:30 -04:00
|
|
|
handleStatusClick = e => {
|
|
|
|
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 09:04:18 -04:00
|
|
|
render () {
|
2019-05-03 10:16:30 -04:00
|
|
|
const { media, status, time, onClose } = this.props;
|
|
|
|
|
2017-04-13 09:04:18 -04:00
|
|
|
return (
|
2018-04-08 17:15:25 -04:00
|
|
|
<div className='modal-root__modal video-modal'>
|
2019-10-02 21:34:58 -04:00
|
|
|
<div className='video-modal__container'>
|
2017-09-13 21:39:10 -04:00
|
|
|
<Video
|
|
|
|
preview={media.get('preview_url')}
|
2019-04-26 21:24:09 -04:00
|
|
|
blurhash={media.get('blurhash')}
|
2017-09-13 21:39:10 -04:00
|
|
|
src={media.get('url')}
|
|
|
|
startTime={time}
|
|
|
|
onCloseVideo={onClose}
|
2018-01-13 13:41:20 -05:00
|
|
|
detailed
|
2018-09-11 09:45:51 -04:00
|
|
|
alt={media.get('description')}
|
2017-09-13 21:39:10 -04:00
|
|
|
/>
|
2017-04-13 09:04:18 -04:00
|
|
|
</div>
|
2019-10-02 21:34:58 -04:00
|
|
|
|
|
|
|
{status && (
|
|
|
|
<div className={classNames('media-modal__meta')}>
|
|
|
|
<a href={status.get('url')} onClick={this.handleStatusClick}><Icon id='comments' /> <FormattedMessage id='lightbox.view_context' defaultMessage='View context' /></a>
|
|
|
|
</div>
|
|
|
|
)}
|
2017-04-13 09:04:18 -04:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|