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.6KB

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