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.js 3.3KB

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