Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Conference.native.js 6.3KB

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