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

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