2017-08-29 23:30:21 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-08-24 15:58:22 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-09-01 04:13:59 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-09-05 22:45:20 +00:00
|
|
|
import { ActivityIndicator } from 'react-native';
|
2017-08-24 15:58:22 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2017-09-01 04:13:59 +00:00
|
|
|
import { destroyLocalTracks } from '../../base/tracks';
|
|
|
|
|
|
|
|
import { isWelcomePageAppEnabled } from '../functions';
|
2017-09-05 22:45:20 +00:00
|
|
|
import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
|
2017-08-24 15:58:22 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
/**
|
2017-09-01 04:13:59 +00:00
|
|
|
* The React <tt>Component</tt> displayed by <tt>AbstractApp</tt> when it has no
|
|
|
|
* <tt>Route</tt> to render. Renders a progress indicator when there are ongoing
|
|
|
|
* network requests.
|
2017-08-24 15:58:22 +00:00
|
|
|
*/
|
2017-09-01 04:13:59 +00:00
|
|
|
class BlankPage extends Component {
|
2017-08-24 15:58:22 +00:00
|
|
|
/**
|
|
|
|
* <tt>BlankPage</tt> React <tt>Component</tt>'s prop types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
static propTypes = {
|
|
|
|
/**
|
|
|
|
* Indicates whether there is network activity i.e. ongoing network
|
|
|
|
* requests.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2017-09-01 04:13:59 +00:00
|
|
|
_networkActivity: PropTypes.bool,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The indicator which determines whether <tt>WelcomePage</tt> is (to
|
|
|
|
* be) rendered.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_welcomePageEnabled: PropTypes.bool,
|
|
|
|
|
|
|
|
dispatch: PropTypes.func
|
2017-08-24 15:58:22 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 04:13:59 +00:00
|
|
|
/**
|
|
|
|
* Destroys the local tracks (if any) since no media is desired when this
|
|
|
|
* component is rendered.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillMount() {
|
|
|
|
this.props._welcomePageEnabled
|
|
|
|
|| this.props.dispatch(destroyLocalTracks());
|
|
|
|
}
|
|
|
|
|
2017-08-24 15:58:22 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @override
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
return (
|
2017-09-05 22:45:20 +00:00
|
|
|
<LocalVideoTrackUnderlay style = { styles.blankPage }>
|
2017-08-24 15:58:22 +00:00
|
|
|
<ActivityIndicator
|
|
|
|
animating = { this.props._networkActivity }
|
|
|
|
size = { 'large' } />
|
2017-09-05 22:45:20 +00:00
|
|
|
</LocalVideoTrackUnderlay>
|
2017-08-24 15:58:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the React <tt>Component</tt> props of
|
|
|
|
* <tt>BlankPage</tt>.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2017-09-01 04:13:59 +00:00
|
|
|
* _networkActivity: boolean,
|
|
|
|
* _welcomePageEnabled: boolean
|
2017-08-24 15:58:22 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
2017-08-29 23:30:21 +00:00
|
|
|
const { requests } = state['features/network-activity'];
|
2017-08-24 15:58:22 +00:00
|
|
|
|
|
|
|
return {
|
2017-08-29 23:30:21 +00:00
|
|
|
_networkActivity:
|
2017-09-01 04:13:59 +00:00
|
|
|
Boolean(requests && (requests.length || requests.size)),
|
|
|
|
_welcomePageEnabled: isWelcomePageAppEnabled(state)
|
2017-08-24 15:58:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(BlankPage);
|