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.web.js 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // @flow
  2. import _ from 'lodash';
  3. import React, { Component } from 'react';
  4. import { connect as reactReduxConnect } from 'react-redux';
  5. import { connect, disconnect } from '../../base/connection';
  6. import { DialogContainer } from '../../base/dialog';
  7. import { translate } from '../../base/i18n';
  8. import { CalleeInfoContainer } from '../../base/jwt';
  9. import { HideNotificationBarStyle } from '../../base/react';
  10. import { Filmstrip } from '../../filmstrip';
  11. import { LargeVideo } from '../../large-video';
  12. import { NotificationsContainer } from '../../notifications';
  13. import { SidePanel } from '../../side-panel';
  14. import {
  15. Toolbox,
  16. fullScreenChanged,
  17. setToolboxAlwaysVisible,
  18. showToolbox
  19. } from '../../toolbox';
  20. import { maybeShowSuboptimalExperienceNotification } from '../functions';
  21. declare var APP: Object;
  22. declare var interfaceConfig: Object;
  23. /**
  24. * DOM events for when full screen mode has changed. Different browsers need
  25. * different vendor prefixes.
  26. *
  27. * @private
  28. * @type {Array<string>}
  29. */
  30. const FULL_SCREEN_EVENTS = [
  31. 'webkitfullscreenchange',
  32. 'mozfullscreenchange',
  33. 'fullscreenchange'
  34. ];
  35. /**
  36. * The type of the React {@code Component} props of {@link Conference}.
  37. */
  38. type Props = {
  39. /**
  40. * Whether the local participant is recording the conference.
  41. */
  42. _iAmRecorder: boolean,
  43. dispatch: Function,
  44. t: Function
  45. }
  46. /**
  47. * The conference page of the Web application.
  48. */
  49. class Conference extends Component<Props> {
  50. _onFullScreenChange: Function;
  51. _onShowToolbar: Function;
  52. _originalOnShowToolbar: Function;
  53. /**
  54. * Initializes a new Conference instance.
  55. *
  56. * @param {Object} props - The read-only properties with which the new
  57. * instance is to be initialized.
  58. */
  59. constructor(props) {
  60. super(props);
  61. // Throttle and bind this component's mousemove handler to prevent it
  62. // from firing too often.
  63. this._originalOnShowToolbar = this._onShowToolbar;
  64. this._onShowToolbar = _.throttle(
  65. () => this._originalOnShowToolbar(),
  66. 100,
  67. {
  68. leading: true,
  69. trailing: false
  70. });
  71. // Bind event handler so it is only bound once for every instance.
  72. this._onFullScreenChange = this._onFullScreenChange.bind(this);
  73. }
  74. /**
  75. * Until we don't rewrite UI using react components
  76. * we use UI.start from old app. Also method translates
  77. * component right after it has been mounted.
  78. *
  79. * @inheritdoc
  80. */
  81. componentDidMount() {
  82. APP.UI.start();
  83. APP.UI.registerListeners();
  84. APP.UI.bindEvents();
  85. FULL_SCREEN_EVENTS.forEach(name =>
  86. document.addEventListener(name, this._onFullScreenChange));
  87. const { dispatch, t } = this.props;
  88. dispatch(connect());
  89. maybeShowSuboptimalExperienceNotification(dispatch, t);
  90. interfaceConfig.filmStripOnly
  91. && dispatch(setToolboxAlwaysVisible(true));
  92. }
  93. /**
  94. * Disconnect from the conference when component will be
  95. * unmounted.
  96. *
  97. * @inheritdoc
  98. */
  99. componentWillUnmount() {
  100. APP.UI.unregisterListeners();
  101. APP.UI.unbindEvents();
  102. FULL_SCREEN_EVENTS.forEach(name =>
  103. document.removeEventListener(name, this._onFullScreenChange));
  104. APP.conference.isJoined() && this.props.dispatch(disconnect());
  105. }
  106. /**
  107. * Implements React's {@link Component#render()}.
  108. *
  109. * @inheritdoc
  110. * @returns {ReactElement}
  111. */
  112. render() {
  113. const {
  114. VIDEO_QUALITY_LABEL_DISABLED,
  115. // XXX The character casing of the name filmStripOnly utilized by
  116. // interfaceConfig is obsolete but legacy support is required.
  117. filmStripOnly: filmstripOnly
  118. } = interfaceConfig;
  119. const hideVideoQualityLabel
  120. = filmstripOnly
  121. || VIDEO_QUALITY_LABEL_DISABLED
  122. || this.props._iAmRecorder;
  123. return (
  124. <div
  125. id = 'videoconference_page'
  126. onMouseMove = { this._onShowToolbar }>
  127. <div id = 'videospace'>
  128. <LargeVideo
  129. hideVideoQualityLabel = { hideVideoQualityLabel } />
  130. <Filmstrip filmstripOnly = { filmstripOnly } />
  131. </div>
  132. { filmstripOnly || <Toolbox /> }
  133. { filmstripOnly || <SidePanel /> }
  134. <DialogContainer />
  135. <NotificationsContainer />
  136. <CalleeInfoContainer />
  137. {/*
  138. * Temasys automatically injects a notification bar, if
  139. * necessary, displayed at the top of the page notifying that
  140. * WebRTC is not installed or supported. We do not need/want
  141. * the notification bar in question because we have whole pages
  142. * dedicated to the respective scenarios.
  143. */}
  144. <HideNotificationBarStyle />
  145. </div>
  146. );
  147. }
  148. /**
  149. * Updates the Redux state when full screen mode has been enabled or
  150. * disabled.
  151. *
  152. * @private
  153. * @returns {void}
  154. */
  155. _onFullScreenChange() {
  156. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  157. }
  158. /**
  159. * Displays the toolbar.
  160. *
  161. * @private
  162. * @returns {void}
  163. */
  164. _onShowToolbar() {
  165. this.props.dispatch(showToolbox());
  166. }
  167. }
  168. /**
  169. * Maps (parts of) the Redux state to the associated props for the
  170. * {@code Conference} component.
  171. *
  172. * @param {Object} state - The Redux state.
  173. * @private
  174. * @returns {{
  175. * _iAmRecorder: boolean
  176. * }}
  177. */
  178. function _mapStateToProps(state) {
  179. const { iAmRecorder } = state['features/base/config'];
  180. return {
  181. /**
  182. * Whether the local participant is recording the conference.
  183. *
  184. * @private
  185. */
  186. _iAmRecorder: iAmRecorder
  187. };
  188. }
  189. export default reactReduxConnect(_mapStateToProps)(translate(Conference));