2017-06-04 10:40:14 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-04-10 02:28:54 +08:00
|
|
|
import cx from 'classnames';
|
2018-04-18 01:55:07 +08:00
|
|
|
import VideoProviderContainer from '/imports/ui/components/video-provider/container';
|
|
|
|
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from './styles';
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-04-12 02:50:14 +08:00
|
|
|
children: PropTypes.element.isRequired,
|
2018-04-10 02:28:54 +08:00
|
|
|
floatingOverlay: PropTypes.bool,
|
|
|
|
hideOverlay: PropTypes.bool,
|
2016-05-04 04:40:46 +08:00
|
|
|
};
|
2016-05-03 06:42:54 +08:00
|
|
|
|
2017-10-11 06:08:51 +08:00
|
|
|
const defaultProps = {
|
2018-04-10 02:28:54 +08:00
|
|
|
floatingOverlay: false,
|
|
|
|
hideOverlay: true,
|
2017-10-11 06:08:51 +08:00
|
|
|
};
|
|
|
|
|
2018-04-27 23:11:40 +08:00
|
|
|
|
2016-05-03 06:42:54 +08:00
|
|
|
export default class Media extends Component {
|
2018-04-12 02:50:14 +08:00
|
|
|
componentWillUpdate() {
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
2016-05-04 04:40:46 +08:00
|
|
|
}
|
|
|
|
|
2019-04-19 02:48:39 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
const {
|
|
|
|
userWasInWebcam,
|
|
|
|
audioModalIsOpen,
|
|
|
|
joinVideo,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
audioModalIsOpen: oldAudioModalIsOpen,
|
|
|
|
} = prevProps;
|
|
|
|
|
|
|
|
if ((!audioModalIsOpen && oldAudioModalIsOpen) && userWasInWebcam) {
|
|
|
|
Session.set('userWasInWebcam', false);
|
|
|
|
joinVideo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
render() {
|
|
|
|
const {
|
2019-04-19 02:48:39 +08:00
|
|
|
swapLayout,
|
|
|
|
floatingOverlay,
|
|
|
|
hideOverlay,
|
|
|
|
disableVideo,
|
|
|
|
children,
|
|
|
|
audioModalIsOpen,
|
2018-04-12 02:50:14 +08:00
|
|
|
} = this.props;
|
2018-04-10 02:28:54 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const contentClassName = cx({
|
|
|
|
[styles.content]: true,
|
|
|
|
});
|
2016-05-04 04:40:46 +08:00
|
|
|
|
2018-04-12 02:50:14 +08:00
|
|
|
const overlayClassName = cx({
|
|
|
|
[styles.overlay]: true,
|
|
|
|
[styles.hideOverlay]: hideOverlay,
|
|
|
|
[styles.floatingOverlay]: floatingOverlay,
|
|
|
|
});
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.container}>
|
2018-04-12 02:50:14 +08:00
|
|
|
<div className={!swapLayout ? contentClassName : overlayClassName}>
|
2018-12-18 05:01:23 +08:00
|
|
|
{children}
|
2018-04-12 02:50:14 +08:00
|
|
|
</div>
|
|
|
|
<div className={!swapLayout ? overlayClassName : contentClassName}>
|
2019-04-19 02:48:39 +08:00
|
|
|
{ !disableVideo && !audioModalIsOpen ? <VideoProviderContainer /> : null }
|
2018-04-12 02:50:14 +08:00
|
|
|
</div>
|
2016-05-03 06:42:54 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 04:40:46 +08:00
|
|
|
|
|
|
|
Media.propTypes = propTypes;
|
2017-10-11 06:08:51 +08:00
|
|
|
Media.defaultProps = defaultProps;
|