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

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