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

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