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

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 { KnockingParticipantList, LobbyScreen } from '../../../lobby';
  14. import { Prejoin, isPrejoinPageVisible } from '../../../prejoin';
  15. import { fullScreenChanged, setToolboxAlwaysVisible, showToolbox } from '../../../toolbox/actions.web';
  16. import { Toolbox } from '../../../toolbox/components/web';
  17. import { LAYOUTS, getCurrentLayout } from '../../../video-layout';
  18. import { maybeShowSuboptimalExperienceNotification } from '../../functions';
  19. import {
  20. AbstractConference,
  21. abstractMapStateToProps
  22. } from '../AbstractConference';
  23. import type { AbstractProps } from '../AbstractConference';
  24. import Labels from './Labels';
  25. import { default as Notice } from './Notice';
  26. declare var APP: Object;
  27. declare var config: Object;
  28. declare var interfaceConfig: Object;
  29. /**
  30. * DOM events for when full screen mode has changed. Different browsers need
  31. * different vendor prefixes.
  32. *
  33. * @private
  34. * @type {Array<string>}
  35. */
  36. const FULL_SCREEN_EVENTS = [
  37. 'webkitfullscreenchange',
  38. 'mozfullscreenchange',
  39. 'fullscreenchange'
  40. ];
  41. /**
  42. * The CSS class to apply to the root element of the conference so CSS can
  43. * modify the app layout.
  44. *
  45. * @private
  46. * @type {Object}
  47. */
  48. const LAYOUT_CLASSNAMES = {
  49. [LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW]: 'horizontal-filmstrip',
  50. [LAYOUTS.TILE_VIEW]: 'tile-view',
  51. [LAYOUTS.VERTICAL_FILMSTRIP_VIEW]: 'vertical-filmstrip'
  52. };
  53. /**
  54. * The type of the React {@code Component} props of {@link Conference}.
  55. */
  56. type Props = AbstractProps & {
  57. /**
  58. * Whether the local participant is recording the conference.
  59. */
  60. _iAmRecorder: boolean,
  61. /**
  62. * Returns true if the 'lobby screen' is visible.
  63. */
  64. _isLobbyScreenVisible: 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. // XXX The character casing of the name filmStripOnly utilized by
  156. // interfaceConfig is obsolete but legacy support is required.
  157. filmStripOnly: filmstripOnly
  158. } = interfaceConfig;
  159. const {
  160. _iAmRecorder,
  161. _isLobbyScreenVisible,
  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. <div id = 'videospace'>
  173. <LargeVideo />
  174. <KnockingParticipantList />
  175. <Filmstrip filmstripOnly = { filmstripOnly } />
  176. { hideLabels || <Labels /> }
  177. </div>
  178. { filmstripOnly || _showPrejoin || _isLobbyScreenVisible || <Toolbox /> }
  179. { filmstripOnly || <Chat /> }
  180. { this.renderNotificationsContainer() }
  181. <CalleeInfoContainer />
  182. { !filmstripOnly && _showPrejoin && <Prejoin />}
  183. </div>
  184. );
  185. }
  186. /**
  187. * Updates the Redux state when full screen mode has been enabled or
  188. * disabled.
  189. *
  190. * @private
  191. * @returns {void}
  192. */
  193. _onFullScreenChange() {
  194. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  195. }
  196. /**
  197. * Displays the toolbar.
  198. *
  199. * @private
  200. * @returns {void}
  201. */
  202. _onShowToolbar() {
  203. this.props.dispatch(showToolbox());
  204. }
  205. /**
  206. * Until we don't rewrite UI using react components
  207. * we use UI.start from old app. Also method translates
  208. * component right after it has been mounted.
  209. *
  210. * @inheritdoc
  211. */
  212. _start() {
  213. APP.UI.start();
  214. APP.UI.registerListeners();
  215. APP.UI.bindEvents();
  216. FULL_SCREEN_EVENTS.forEach(name =>
  217. document.addEventListener(name, this._onFullScreenChange));
  218. const { dispatch, t } = this.props;
  219. dispatch(connect());
  220. maybeShowSuboptimalExperienceNotification(dispatch, t);
  221. interfaceConfig.filmStripOnly
  222. && dispatch(setToolboxAlwaysVisible(true));
  223. }
  224. }
  225. /**
  226. * Maps (parts of) the Redux state to the associated props for the
  227. * {@code Conference} component.
  228. *
  229. * @param {Object} state - The Redux state.
  230. * @private
  231. * @returns {Props}
  232. */
  233. function _mapStateToProps(state) {
  234. return {
  235. ...abstractMapStateToProps(state),
  236. _iAmRecorder: state['features/base/config'].iAmRecorder,
  237. _isLobbyScreenVisible: state['features/base/dialog']?.component === LobbyScreen,
  238. _layoutClassName: LAYOUT_CLASSNAMES[getCurrentLayout(state)],
  239. _roomName: getConferenceNameForTitle(state),
  240. _showPrejoin: isPrejoinPageVisible(state)
  241. };
  242. }
  243. export default reactReduxConnect(_mapStateToProps)(translate(Conference));