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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // @flow
  2. import _ from 'lodash';
  3. import React from 'react';
  4. import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout';
  5. import { getConferenceNameForTitle } from '../../../base/conference';
  6. import { connect, disconnect } from '../../../base/connection';
  7. import { translate } from '../../../base/i18n';
  8. import { connect as reactReduxConnect } from '../../../base/redux';
  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 {
  15. Toolbox,
  16. fullScreenChanged,
  17. setToolboxAlwaysVisible,
  18. showToolbox
  19. } from '../../../toolbox';
  20. import { LAYOUTS, getCurrentLayout } from '../../../video-layout';
  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. // 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 hideLabels = filmstripOnly || _iAmRecorder;
  166. return (
  167. <div
  168. className = { _layoutClassName }
  169. id = 'videoconference_page'
  170. onMouseMove = { this._onShowToolbar }>
  171. <Notice />
  172. <Subject />
  173. <InviteMore />
  174. <div id = 'videospace'>
  175. <LargeVideo />
  176. { hideLabels
  177. || <Labels /> }
  178. <Filmstrip filmstripOnly = { filmstripOnly } />
  179. </div>
  180. { filmstripOnly || _showPrejoin || <Toolbox /> }
  181. { filmstripOnly || <Chat /> }
  182. { this.renderNotificationsContainer() }
  183. { !filmstripOnly && _showPrejoin && <Prejoin />}
  184. <CalleeInfoContainer />
  185. </div>
  186. );
  187. }
  188. /**
  189. * Updates the Redux state when full screen mode has been enabled or
  190. * disabled.
  191. *
  192. * @private
  193. * @returns {void}
  194. */
  195. _onFullScreenChange() {
  196. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  197. }
  198. /**
  199. * Displays the toolbar.
  200. *
  201. * @private
  202. * @returns {void}
  203. */
  204. _onShowToolbar() {
  205. this.props.dispatch(showToolbox());
  206. }
  207. /**
  208. * Until we don't rewrite UI using react components
  209. * we use UI.start from old app. Also method translates
  210. * component right after it has been mounted.
  211. *
  212. * @inheritdoc
  213. */
  214. _start() {
  215. APP.UI.start();
  216. APP.UI.registerListeners();
  217. APP.UI.bindEvents();
  218. FULL_SCREEN_EVENTS.forEach(name =>
  219. document.addEventListener(name, this._onFullScreenChange));
  220. const { dispatch, t } = this.props;
  221. dispatch(connect());
  222. maybeShowSuboptimalExperienceNotification(dispatch, t);
  223. interfaceConfig.filmStripOnly
  224. && dispatch(setToolboxAlwaysVisible(true));
  225. }
  226. }
  227. /**
  228. * Maps (parts of) the Redux state to the associated props for the
  229. * {@code Conference} component.
  230. *
  231. * @param {Object} state - The Redux state.
  232. * @private
  233. * @returns {Props}
  234. */
  235. function _mapStateToProps(state) {
  236. return {
  237. ...abstractMapStateToProps(state),
  238. _iAmRecorder: state['features/base/config'].iAmRecorder,
  239. _layoutClassName: LAYOUT_CLASSNAMES[getCurrentLayout(state)],
  240. _roomName: getConferenceNameForTitle(state),
  241. _showPrejoin: isPrejoinPageVisible(state)
  242. };
  243. }
  244. export default reactReduxConnect(_mapStateToProps)(translate(Conference));