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 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 PasswordRequiredPrompt from './PasswordRequiredPrompt';
  9. import { styles } from './styles';
  10. /**
  11. * The timeout in milliseconds after which the toolbar will be hidden.
  12. */
  13. const TOOLBAR_TIMEOUT_MS = 5000;
  14. /**
  15. * The conference page of the application.
  16. */
  17. class Conference extends Component {
  18. /**
  19. * Conference component's property types.
  20. *
  21. * @static
  22. */
  23. static propTypes = {
  24. /**
  25. * The indicator which determines whether a password is required to join
  26. * the conference and has not been provided yet.
  27. *
  28. * @private
  29. * @type {JitsiConference}
  30. */
  31. _passwordRequired: React.PropTypes.object,
  32. dispatch: React.PropTypes.func
  33. }
  34. /**
  35. * Initializes a new Conference instance.
  36. *
  37. * @param {Object} props - The read-only properties with which the new
  38. * instance is to be initialized.
  39. */
  40. constructor(props) {
  41. super(props);
  42. this.state = { toolbarVisible: false };
  43. /**
  44. * The numerical ID of the timeout in milliseconds after which the
  45. * toolbar will be hidden. To be used with
  46. * {@link WindowTimers#clearTimeout()}.
  47. *
  48. * @private
  49. */
  50. this._toolbarTimeout = undefined;
  51. // Bind event handlers so they are only bound once for every instance.
  52. this._onClick = this._onClick.bind(this);
  53. }
  54. /**
  55. * Inits new connection and conference when conference screen is entered.
  56. *
  57. * @inheritdoc
  58. * @returns {void}
  59. */
  60. componentWillMount() {
  61. this.props.dispatch(connect());
  62. }
  63. /**
  64. * Destroys connection, conference and local tracks when conference screen
  65. * is left. Clears {@link #_toolbarTimeout} before the component unmounts.
  66. *
  67. * @inheritdoc
  68. * @returns {void}
  69. */
  70. componentWillUnmount() {
  71. this._clearToolbarTimeout();
  72. this.props.dispatch(disconnect());
  73. }
  74. /**
  75. * Implements React's {@link Component#render()}.
  76. *
  77. * @inheritdoc
  78. * @returns {ReactElement}
  79. */
  80. render() {
  81. const toolbarVisible = this.state.toolbarVisible;
  82. return (
  83. <Container
  84. onClick = { this._onClick }
  85. style = { styles.conference }
  86. touchFeedback = { false }>
  87. <LargeVideo />
  88. <Toolbar visible = { toolbarVisible } />
  89. <FilmStrip visible = { !toolbarVisible } />
  90. {
  91. this._renderPrompt()
  92. }
  93. </Container>
  94. );
  95. }
  96. /**
  97. * Clears {@link #_toolbarTimeout} if any.
  98. *
  99. * @private
  100. * @returns {void}
  101. */
  102. _clearToolbarTimeout() {
  103. if (this._toolbarTimeout) {
  104. clearTimeout(this._toolbarTimeout);
  105. this._toolbarTimeout = undefined;
  106. }
  107. }
  108. /**
  109. * Changes the value of the toolbarVisible state, thus allowing us to
  110. * 'switch' between toolbar and filmstrip views and change the visibility of
  111. * the above.
  112. *
  113. * @private
  114. * @returns {void}
  115. */
  116. _onClick() {
  117. const toolbarVisible = !this.state.toolbarVisible;
  118. this.setState({ toolbarVisible });
  119. this._clearToolbarTimeout();
  120. if (toolbarVisible) {
  121. this._toolbarTimeout
  122. = setTimeout(this._onClick, TOOLBAR_TIMEOUT_MS);
  123. }
  124. }
  125. /**
  126. * Renders a prompt if necessary such as when a password is required to join
  127. * the conference.
  128. *
  129. * @private
  130. * @returns {ReactElement}
  131. */
  132. _renderPrompt() {
  133. const passwordRequired = this.props._passwordRequired;
  134. if (passwordRequired) {
  135. return (
  136. <PasswordRequiredPrompt conference = { passwordRequired } />
  137. );
  138. }
  139. return null;
  140. }
  141. }
  142. /**
  143. * Maps (parts of) the Redux state to the associated Conference's props.
  144. *
  145. * @param {Object} state - The Redux state.
  146. * @returns {{
  147. * _passwordRequired: boolean
  148. * }}
  149. */
  150. function mapStateToProps(state) {
  151. return {
  152. /**
  153. * The indicator which determines whether a password is required to join
  154. * the conference and has not been provided yet.
  155. *
  156. * @private
  157. * @type {JitsiConference}
  158. */
  159. _passwordRequired: state['features/base/conference'].passwordRequired
  160. };
  161. }
  162. export default reactReduxConnect(mapStateToProps)(Conference);