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.

Conference.native.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import React, { Component } from 'react';
  2. import { connect as reactReduxConnect } from 'react-redux';
  3. import { connect, disconnect } from '../../base/connection';
  4. import { Container } from '../../base/react';
  5. import { FilmStrip } from '../../filmStrip';
  6. import { LargeVideo } from '../../largeVideo';
  7. import { Toolbar } from '../../toolbar';
  8. import { styles } from './styles';
  9. /**
  10. * The timeout in milliseconds after which the toolbar will be hidden.
  11. */
  12. const TOOLBAR_TIMEOUT_MS = 5000;
  13. /**
  14. * The conference page of the application.
  15. */
  16. class Conference extends Component {
  17. /**
  18. * Conference component's property types.
  19. *
  20. * @static
  21. */
  22. static propTypes = {
  23. dispatch: React.PropTypes.func
  24. }
  25. /**
  26. * Initializes a new Conference instance.
  27. *
  28. * @param {Object} props - The read-only properties with which the new
  29. * instance is to be initialized.
  30. */
  31. constructor(props) {
  32. super(props);
  33. this.state = { toolbarVisible: false };
  34. /**
  35. * The numerical ID of the timeout in milliseconds after which the
  36. * toolbar will be hidden. To be used with
  37. * {@link WindowTimers#clearTimeout()}.
  38. *
  39. * @private
  40. */
  41. this._toolbarTimeout = undefined;
  42. // Bind event handlers so they are only bound once for every instance.
  43. this._onClick = this._onClick.bind(this);
  44. }
  45. /**
  46. * Inits new connection and conference when conference screen is entered.
  47. *
  48. * @inheritdoc
  49. * @returns {void}
  50. */
  51. componentWillMount() {
  52. this.props.dispatch(connect());
  53. }
  54. /**
  55. * Destroys connection, conference and local tracks when conference screen
  56. * is left. Clears {@link #_toolbarTimeout} before the component unmounts.
  57. *
  58. * @inheritdoc
  59. * @returns {void}
  60. */
  61. componentWillUnmount() {
  62. this._clearToolbarTimeout();
  63. this.props.dispatch(disconnect());
  64. }
  65. /**
  66. * Implements React's {@link Component#render()}.
  67. *
  68. * @inheritdoc
  69. * @returns {ReactElement}
  70. */
  71. render() {
  72. const toolbarVisible = this.state.toolbarVisible;
  73. return (
  74. <Container
  75. onClick = { this._onClick }
  76. style = { styles.conference }
  77. touchFeedback = { false }>
  78. <LargeVideo />
  79. <Toolbar visible = { toolbarVisible } />
  80. <FilmStrip visible = { !toolbarVisible } />
  81. </Container>
  82. );
  83. }
  84. /**
  85. * Clears {@link #_toolbarTimeout} if any.
  86. *
  87. * @private
  88. * @returns {void}
  89. */
  90. _clearToolbarTimeout() {
  91. if (this._toolbarTimeout) {
  92. clearTimeout(this._toolbarTimeout);
  93. this._toolbarTimeout = undefined;
  94. }
  95. }
  96. /**
  97. * Changes the value of the toolbarVisible state, thus allowing us to
  98. * 'switch' between toolbar and filmstrip views and change the visibility of
  99. * the above.
  100. *
  101. * @private
  102. * @returns {void}
  103. */
  104. _onClick() {
  105. const toolbarVisible = !this.state.toolbarVisible;
  106. this.setState({ toolbarVisible });
  107. this._clearToolbarTimeout();
  108. if (toolbarVisible) {
  109. this._toolbarTimeout
  110. = setTimeout(this._onClick, TOOLBAR_TIMEOUT_MS);
  111. }
  112. }
  113. }
  114. export default reactReduxConnect()(Conference);