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.js 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. // @flow
  2. import _ from 'lodash';
  3. import React from 'react';
  4. import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout';
  5. import { connect, disconnect } from '../../../base/connection';
  6. import { translate } from '../../../base/i18n';
  7. import { connect as reactReduxConnect } from '../../../base/redux';
  8. import { Chat } from '../../../chat';
  9. import { Filmstrip } from '../../../filmstrip';
  10. import { CalleeInfoContainer } from '../../../invite';
  11. import { LargeVideo } from '../../../large-video';
  12. import { LAYOUTS, getCurrentLayout } from '../../../video-layout';
  13. import {
  14. Toolbox,
  15. fullScreenChanged,
  16. setToolboxAlwaysVisible,
  17. showToolbox
  18. } from '../../../toolbox';
  19. import { maybeShowSuboptimalExperienceNotification } from '../../functions';
  20. import Labels from './Labels';
  21. import { default as Notice } from './Notice';
  22. import { default as Subject } from './Subject';
  23. import {
  24. AbstractConference,
  25. abstractMapStateToProps
  26. } from '../AbstractConference';
  27. import type { AbstractProps } from '../AbstractConference';
  28. declare var APP: Object;
  29. declare var config: Object;
  30. declare var interfaceConfig: Object;
  31. /**
  32. * DOM events for when full screen mode has changed. Different browsers need
  33. * different vendor prefixes.
  34. *
  35. * @private
  36. * @type {Array<string>}
  37. */
  38. const FULL_SCREEN_EVENTS = [
  39. 'webkitfullscreenchange',
  40. 'mozfullscreenchange',
  41. 'fullscreenchange'
  42. ];
  43. /**
  44. * The CSS class to apply to the root element of the conference so CSS can
  45. * modify the app layout.
  46. *
  47. * @private
  48. * @type {Object}
  49. */
  50. const LAYOUT_CLASSNAMES = {
  51. [LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW]: 'horizontal-filmstrip',
  52. [LAYOUTS.TILE_VIEW]: 'tile-view',
  53. [LAYOUTS.VERTICAL_FILMSTRIP_VIEW]: 'vertical-filmstrip'
  54. };
  55. /**
  56. * The type of the React {@code Component} props of {@link Conference}.
  57. */
  58. type Props = AbstractProps & {
  59. /**
  60. * Whether the local participant is recording the conference.
  61. */
  62. _iAmRecorder: boolean,
  63. /**
  64. * The CSS class to apply to the root of {@link Conference} to modify the
  65. * application layout.
  66. */
  67. _layoutClassName: string,
  68. dispatch: Function,
  69. t: Function
  70. }
  71. /**
  72. * The conference page of the Web application.
  73. */
  74. class Conference extends AbstractConference<Props, *> {
  75. _onFullScreenChange: Function;
  76. _onShowToolbar: Function;
  77. _originalOnShowToolbar: Function;
  78. /**
  79. * Initializes a new Conference instance.
  80. *
  81. * @param {Object} props - The read-only properties with which the new
  82. * instance is to be initialized.
  83. */
  84. constructor(props) {
  85. super(props);
  86. // Throttle and bind this component's mousemove handler to prevent it
  87. // from firing too often.
  88. this._originalOnShowToolbar = this._onShowToolbar;
  89. this._onShowToolbar = _.throttle(
  90. () => this._originalOnShowToolbar(),
  91. 100,
  92. {
  93. leading: true,
  94. trailing: false
  95. });
  96. // Bind event handler so it is only bound once for every instance.
  97. this._onFullScreenChange = this._onFullScreenChange.bind(this);
  98. }
  99. /**
  100. * Start the connection and get the UI ready for the conference.
  101. *
  102. * @inheritdoc
  103. */
  104. componentDidMount() {
  105. document.title = interfaceConfig.APP_NAME;
  106. this._start();
  107. }
  108. /**
  109. * Calls into legacy UI to update the application layout, if necessary.
  110. *
  111. * @inheritdoc
  112. * returns {void}
  113. */
  114. componentDidUpdate(prevProps) {
  115. if (this.props._shouldDisplayTileView
  116. === prevProps._shouldDisplayTileView) {
  117. return;
  118. }
  119. // TODO: For now VideoLayout is being called as LargeVideo and Filmstrip
  120. // sizing logic is still handled outside of React. Once all components
  121. // are in react they should calculate size on their own as much as
  122. // possible and pass down sizings.
  123. VideoLayout.refreshLayout();
  124. }
  125. /**
  126. * Disconnect from the conference when component will be
  127. * unmounted.
  128. *
  129. * @inheritdoc
  130. */
  131. componentWillUnmount() {
  132. APP.UI.unbindEvents();
  133. FULL_SCREEN_EVENTS.forEach(name =>
  134. document.removeEventListener(name, this._onFullScreenChange));
  135. APP.conference.isJoined() && this.props.dispatch(disconnect());
  136. }
  137. /**
  138. * Implements React's {@link Component#render()}.
  139. *
  140. * @inheritdoc
  141. * @returns {ReactElement}
  142. */
  143. render() {
  144. const {
  145. VIDEO_QUALITY_LABEL_DISABLED,
  146. // XXX The character casing of the name filmStripOnly utilized by
  147. // interfaceConfig is obsolete but legacy support is required.
  148. filmStripOnly: filmstripOnly
  149. } = interfaceConfig;
  150. const hideVideoQualityLabel
  151. = filmstripOnly
  152. || VIDEO_QUALITY_LABEL_DISABLED
  153. || this.props._iAmRecorder;
  154. return (
  155. <div
  156. className = { this.props._layoutClassName }
  157. id = 'videoconference_page'
  158. onMouseMove = { this._onShowToolbar }>
  159. <Notice />
  160. <Subject />
  161. <div id = 'videospace'>
  162. <LargeVideo />
  163. { hideVideoQualityLabel
  164. || <Labels /> }
  165. <Filmstrip filmstripOnly = { filmstripOnly } />
  166. </div>
  167. { filmstripOnly || <Toolbox /> }
  168. { filmstripOnly || <Chat /> }
  169. { this.renderNotificationsContainer() }
  170. <CalleeInfoContainer />
  171. </div>
  172. );
  173. }
  174. /**
  175. * Updates the Redux state when full screen mode has been enabled or
  176. * disabled.
  177. *
  178. * @private
  179. * @returns {void}
  180. */
  181. _onFullScreenChange() {
  182. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  183. }
  184. /**
  185. * Displays the toolbar.
  186. *
  187. * @private
  188. * @returns {void}
  189. */
  190. _onShowToolbar() {
  191. this.props.dispatch(showToolbox());
  192. }
  193. /**
  194. * Until we don't rewrite UI using react components
  195. * we use UI.start from old app. Also method translates
  196. * component right after it has been mounted.
  197. *
  198. * @inheritdoc
  199. */
  200. _start() {
  201. APP.UI.start();
  202. APP.UI.registerListeners();
  203. APP.UI.bindEvents();
  204. FULL_SCREEN_EVENTS.forEach(name =>
  205. document.addEventListener(name, this._onFullScreenChange));
  206. const { dispatch, t } = this.props;
  207. dispatch(connect());
  208. maybeShowSuboptimalExperienceNotification(dispatch, t);
  209. interfaceConfig.filmStripOnly
  210. && dispatch(setToolboxAlwaysVisible(true));
  211. }
  212. }
  213. /**
  214. * Maps (parts of) the Redux state to the associated props for the
  215. * {@code Conference} component.
  216. *
  217. * @param {Object} state - The Redux state.
  218. * @private
  219. * @returns {Props}
  220. */
  221. function _mapStateToProps(state) {
  222. const currentLayout = getCurrentLayout(state);
  223. return {
  224. ...abstractMapStateToProps(state),
  225. _iAmRecorder: state['features/base/config'].iAmRecorder,
  226. _layoutClassName: LAYOUT_CLASSNAMES[currentLayout]
  227. };
  228. }
  229. export default reactReduxConnect(_mapStateToProps)(translate(Conference));