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

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