2016-10-05 14:36:59 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect as reactReduxConnect } from 'react-redux';
|
|
|
|
|
2016-12-12 00:29:13 +00:00
|
|
|
import { connect, disconnect } from '../../base/connection';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Container } from '../../base/react';
|
2017-01-17 14:44:50 +00:00
|
|
|
import { FilmStrip } from '../../film-strip';
|
|
|
|
import { LargeVideo } from '../../large-video';
|
2016-12-13 09:14:04 +00:00
|
|
|
import { RoomLockPrompt } from '../../room-lock';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Toolbar } from '../../toolbar';
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
import PasswordRequiredPrompt from './PasswordRequiredPrompt';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { styles } from './styles';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The timeout in milliseconds after which the toolbar will be hidden.
|
|
|
|
*/
|
|
|
|
const TOOLBAR_TIMEOUT_MS = 5000;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The conference page of the application.
|
|
|
|
*/
|
|
|
|
class Conference extends Component {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* Conference component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* The indicator which determines whether a password is required to join
|
|
|
|
* the conference and has not been provided yet.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
_passwordRequired: React.PropTypes.object,
|
2016-12-13 09:14:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the user has requested to lock
|
|
|
|
* the conference/room.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
_roomLockRequested: React.PropTypes.object,
|
2016-12-01 01:52:39 +00:00
|
|
|
dispatch: React.PropTypes.func
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new Conference instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2016-12-22 00:07:32 +00:00
|
|
|
this.state = { toolbarVisible: true };
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The numerical ID of the timeout in milliseconds after which the
|
|
|
|
* toolbar will be hidden. To be used with
|
|
|
|
* {@link WindowTimers#clearTimeout()}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
this._toolbarTimeout = undefined;
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
2017-01-03 21:06:47 +00:00
|
|
|
/**
|
|
|
|
* Inits the toolbar timeout after the component is initially rendered.
|
|
|
|
*
|
2017-01-03 21:09:52 +00:00
|
|
|
* @inheritdoc
|
2017-01-03 21:06:47 +00:00
|
|
|
* returns {void}
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
|
|
|
this._setToolbarTimeout(this.state.toolbarVisible);
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Inits new connection and conference when conference screen is entered.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillMount() {
|
|
|
|
this.props.dispatch(connect());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys connection, conference and local tracks when conference screen
|
|
|
|
* is left. Clears {@link #_toolbarTimeout} before the component unmounts.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
this._clearToolbarTimeout();
|
|
|
|
|
|
|
|
this.props.dispatch(disconnect());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const toolbarVisible = this.state.toolbarVisible;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
onClick = { this._onClick }
|
|
|
|
style = { styles.conference }
|
|
|
|
touchFeedback = { false }>
|
|
|
|
|
|
|
|
<LargeVideo />
|
|
|
|
<Toolbar visible = { toolbarVisible } />
|
|
|
|
<FilmStrip visible = { !toolbarVisible } />
|
2016-12-12 01:02:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
this._renderPrompt()
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears {@link #_toolbarTimeout} if any.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_clearToolbarTimeout() {
|
|
|
|
if (this._toolbarTimeout) {
|
|
|
|
clearTimeout(this._toolbarTimeout);
|
|
|
|
this._toolbarTimeout = undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the value of the toolbarVisible state, thus allowing us to
|
|
|
|
* 'switch' between toolbar and filmstrip views and change the visibility of
|
|
|
|
* the above.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const toolbarVisible = !this.state.toolbarVisible;
|
|
|
|
|
|
|
|
this.setState({ toolbarVisible });
|
|
|
|
|
2017-01-03 20:53:52 +00:00
|
|
|
this._setToolbarTimeout(toolbarVisible);
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2016-12-13 09:14:04 +00:00
|
|
|
/**
|
|
|
|
* Renders a prompt if a password is required to join the conference.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderPasswordRequiredPrompt() {
|
|
|
|
const required = this.props._passwordRequired;
|
|
|
|
|
|
|
|
if (required) {
|
|
|
|
return (
|
|
|
|
<PasswordRequiredPrompt conference = { required } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
/**
|
|
|
|
* Renders a prompt if necessary such as when a password is required to join
|
2016-12-13 09:14:04 +00:00
|
|
|
* the conference or the user has requested to lock the conference/room.
|
2016-12-12 01:02:50 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderPrompt() {
|
2016-12-13 09:14:04 +00:00
|
|
|
return (
|
|
|
|
this._renderPasswordRequiredPrompt()
|
|
|
|
|| this._renderRoomLockPrompt()
|
|
|
|
);
|
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2016-12-13 09:14:04 +00:00
|
|
|
/**
|
|
|
|
* Renders a prompt if the user has requested to lock the conference/room.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderRoomLockPrompt() {
|
|
|
|
const requested = this.props._roomLockRequested;
|
|
|
|
|
|
|
|
if (requested) {
|
2016-12-12 01:02:50 +00:00
|
|
|
return (
|
2016-12-13 09:14:04 +00:00
|
|
|
<RoomLockPrompt conference = { requested } />
|
2016-12-12 01:02:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2017-01-03 20:53:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Triggers the default toolbar timeout.
|
|
|
|
*
|
2017-01-03 21:06:47 +00:00
|
|
|
* @param {boolean} toolbarVisible - Indicates if the toolbar is currently
|
2017-01-03 21:09:52 +00:00
|
|
|
* visible.
|
2017-01-03 20:53:52 +00:00
|
|
|
* @private
|
2017-01-03 21:06:47 +00:00
|
|
|
* @returns {void}
|
2017-01-03 20:53:52 +00:00
|
|
|
*/
|
|
|
|
_setToolbarTimeout(toolbarVisible) {
|
|
|
|
this._clearToolbarTimeout();
|
|
|
|
if (toolbarVisible) {
|
|
|
|
this._toolbarTimeout
|
|
|
|
= setTimeout(this._onClick, TOOLBAR_TIMEOUT_MS);
|
|
|
|
}
|
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated Conference's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @returns {{
|
|
|
|
* _passwordRequired: boolean
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether a password is required to join
|
|
|
|
* the conference and has not been provided yet.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
2016-12-13 09:14:04 +00:00
|
|
|
_passwordRequired: state['features/base/conference'].passwordRequired,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether the user has requested to lock
|
|
|
|
* the conference/room.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {JitsiConference}
|
|
|
|
*/
|
|
|
|
_roomLockRequested: state['features/room-lock'].requested
|
2016-12-12 01:02:50 +00:00
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2016-12-12 01:02:50 +00:00
|
|
|
export default reactReduxConnect(mapStateToProps)(Conference);
|