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

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