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

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