You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BlankPage.native.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* @flow */
  2. import PropTypes from 'prop-types';
  3. import React, { Component } from 'react';
  4. import { ActivityIndicator } from 'react-native';
  5. import { connect } from 'react-redux';
  6. import { destroyLocalTracks } from '../../base/tracks';
  7. import { isWelcomePageAppEnabled } from '../functions';
  8. import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
  9. import styles from './styles';
  10. /**
  11. * The React <tt>Component</tt> displayed by <tt>AbstractApp</tt> when it has no
  12. * <tt>Route</tt> to render. Renders a progress indicator when there are ongoing
  13. * network requests.
  14. */
  15. class BlankPage extends Component {
  16. /**
  17. * <tt>BlankPage</tt> React <tt>Component</tt>'s prop types.
  18. *
  19. * @static
  20. */
  21. static propTypes = {
  22. /**
  23. * Indicates whether there is network activity i.e. ongoing network
  24. * requests.
  25. *
  26. * @private
  27. */
  28. _networkActivity: PropTypes.bool,
  29. /**
  30. * The indicator which determines whether <tt>WelcomePage</tt> is (to
  31. * be) rendered.
  32. *
  33. * @private
  34. */
  35. _welcomePageEnabled: PropTypes.bool,
  36. dispatch: PropTypes.func
  37. };
  38. /**
  39. * Destroys the local tracks (if any) since no media is desired when this
  40. * component is rendered.
  41. *
  42. * @inheritdoc
  43. * @returns {void}
  44. */
  45. componentWillMount() {
  46. this.props._welcomePageEnabled
  47. || this.props.dispatch(destroyLocalTracks());
  48. }
  49. /**
  50. * Implements React's {@link Component#render()}.
  51. *
  52. * @inheritdoc
  53. * @override
  54. * @returns {ReactElement}
  55. */
  56. render() {
  57. return (
  58. <LocalVideoTrackUnderlay style = { styles.blankPage }>
  59. <ActivityIndicator
  60. animating = { this.props._networkActivity }
  61. size = { 'large' } />
  62. </LocalVideoTrackUnderlay>
  63. );
  64. }
  65. }
  66. /**
  67. * Maps (parts of) the redux state to the React <tt>Component</tt> props of
  68. * <tt>BlankPage</tt>.
  69. *
  70. * @param {Object} state - The redux state.
  71. * @private
  72. * @returns {{
  73. * _networkActivity: boolean,
  74. * _welcomePageEnabled: boolean
  75. * }}
  76. */
  77. function _mapStateToProps(state) {
  78. const { requests } = state['features/network-activity'];
  79. return {
  80. _networkActivity:
  81. Boolean(requests && (requests.length || requests.size)),
  82. _welcomePageEnabled: isWelcomePageAppEnabled(state)
  83. };
  84. }
  85. export default connect(_mapStateToProps)(BlankPage);