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';
|
2017-03-07 03:34:51 +00:00
|
|
|
import { DialogContainer } from '../../base/dialog';
|
2016-10-05 14:36:59 +00:00
|
|
|
import { Container } from '../../base/react';
|
2017-04-10 17:59:44 +00:00
|
|
|
import { Filmstrip } from '../../filmstrip';
|
2017-01-17 14:44:50 +00:00
|
|
|
import { LargeVideo } from '../../large-video';
|
2017-04-01 05:52:40 +00:00
|
|
|
import { setToolboxVisible, Toolbox } from '../../toolbox';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
import { styles } from './styles';
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* The timeout in milliseconds after which the Toolbox will be hidden.
|
2017-02-02 16:49:14 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {number}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
const _TOOLBOX_TIMEOUT_MS = 5000;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
/**
|
2017-02-02 16:49:14 +00:00
|
|
|
* The conference page of the mobile (i.e. React Native) application.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
class Conference extends Component {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* Conference component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* The handler which dispatches the (redux) action connect.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onConnect: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The handler which dispatches the (redux) action disconnect.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {Function}
|
|
|
|
*/
|
|
|
|
_onDisconnect: React.PropTypes.func,
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* The handler which dispatches the (redux) action setToolboxVisible to
|
|
|
|
* show/hide the Toolbox.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_setToolboxVisible: React.PropTypes.func,
|
2017-02-16 23:02:40 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* The indicator which determines whether the Toolbox is visible.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_toolboxVisible: React.PropTypes.bool
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The numerical ID of the timeout in milliseconds after which the
|
2017-04-01 05:52:40 +00:00
|
|
|
* Toolbox will be hidden. To be used with
|
2016-10-05 14:36:59 +00:00
|
|
|
* {@link WindowTimers#clearTimeout()}.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
this._toolboxTimeout = undefined;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Inits the Toolbox timeout after the component is initially rendered.
|
2017-01-03 21:06:47 +00:00
|
|
|
*
|
2017-01-03 21:09:52 +00:00
|
|
|
* @inheritdoc
|
2017-01-03 21:06:47 +00:00
|
|
|
* returns {void}
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
2017-04-01 05:52:40 +00:00
|
|
|
this._setToolboxTimeout(this.props._toolboxVisible);
|
2017-01-03 21:06:47 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Inits new connection and conference when conference screen is entered.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillMount() {
|
2017-02-16 23:02:40 +00:00
|
|
|
this.props._onConnect();
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys connection, conference and local tracks when conference screen
|
2017-04-01 05:52:40 +00:00
|
|
|
* is left. Clears {@link #_toolboxTimeout} before the component unmounts.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
2017-04-01 05:52:40 +00:00
|
|
|
this._clearToolboxTimeout();
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
this.props._onDisconnect();
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
onClick = { this._onClick }
|
|
|
|
style = { styles.conference }
|
|
|
|
touchFeedback = { false }>
|
|
|
|
|
|
|
|
<LargeVideo />
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
<Toolbox />
|
2017-04-10 17:59:44 +00:00
|
|
|
<Filmstrip />
|
2017-03-07 03:34:51 +00:00
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
<DialogContainer />
|
2016-10-05 14:36:59 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Clears {@link #_toolboxTimeout} if any.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_clearToolboxTimeout() {
|
|
|
|
if (this._toolboxTimeout) {
|
|
|
|
clearTimeout(this._toolboxTimeout);
|
|
|
|
this._toolboxTimeout = undefined;
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Changes the value of the toolboxVisible state, thus allowing us to switch
|
2017-04-10 17:59:44 +00:00
|
|
|
* between Toolbox and Filmstrip and change their visibility.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
2017-04-01 05:52:40 +00:00
|
|
|
const toolboxVisible = !this.props._toolboxVisible;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
this.props._setToolboxVisible(toolboxVisible);
|
|
|
|
this._setToolboxTimeout(toolboxVisible);
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
|
2017-01-03 20:53:52 +00:00
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Triggers the default Toolbox timeout.
|
2017-01-03 20:53:52 +00:00
|
|
|
*
|
2017-04-01 05:52:40 +00:00
|
|
|
* @param {boolean} toolboxVisible - Indicates whether the Toolbox is
|
|
|
|
* currently 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
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_setToolboxTimeout(toolboxVisible) {
|
|
|
|
this._clearToolboxTimeout();
|
|
|
|
if (toolboxVisible) {
|
|
|
|
this._toolboxTimeout
|
|
|
|
= setTimeout(this._onClick, _TOOLBOX_TIMEOUT_MS);
|
2017-01-03 20:53:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-12 01:02:50 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 23:02:40 +00:00
|
|
|
/**
|
|
|
|
* Maps dispatching of some action to React component props.
|
|
|
|
*
|
|
|
|
* @param {Function} dispatch - Redux action dispatcher.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
|
|
|
* _onConnect: Function,
|
|
|
|
* _onDisconnect: Function,
|
2017-04-01 05:52:40 +00:00
|
|
|
* _setToolboxVisible: Function
|
2017-02-16 23:02:40 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapDispatchToProps(dispatch) {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Dispatched an action connecting to the conference.
|
|
|
|
*
|
|
|
|
* @returns {Object} Dispatched action.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_onConnect() {
|
|
|
|
return dispatch(connect());
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatches an action disconnecting from the conference.
|
|
|
|
*
|
|
|
|
* @returns {Object} Dispatched action.
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_onDisconnect() {
|
|
|
|
return dispatch(disconnect());
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* Dispatches an action changing the visiblity of the Toolbox.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
2017-04-01 05:52:40 +00:00
|
|
|
* @param {boolean} visible - True to show the Toolbox or false to hide
|
|
|
|
* it.
|
2017-02-16 23:02:40 +00:00
|
|
|
* @returns {Object} Dispatched action.
|
|
|
|
* @private
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_setToolboxVisible(visible: boolean) {
|
|
|
|
return dispatch(setToolboxVisible(visible));
|
2017-02-16 23:02:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated Conference's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2017-04-01 05:52:40 +00:00
|
|
|
* _toolboxVisible: boolean
|
2017-02-16 23:02:40 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
/**
|
2017-04-01 05:52:40 +00:00
|
|
|
* The indicator which determines whether the Toolbox is visible.
|
2017-02-16 23:02:40 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2017-04-01 05:52:40 +00:00
|
|
|
_toolboxVisible: state['features/toolbox'].visible
|
2017-02-16 23:02:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
|
|
|
|
Conference);
|