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

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