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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 } 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. * The CSS class to apply to the root of {@link Conference} to modify the
  69. * application layout.
  70. */
  71. _layoutClassName: string,
  72. /**
  73. * Name for this conference room.
  74. */
  75. _roomName: string,
  76. /**
  77. * If prejoin page is visible or not.
  78. */
  79. _showPrejoin: boolean,
  80. dispatch: Function,
  81. t: Function
  82. }
  83. /**
  84. * The conference page of the Web application.
  85. */
  86. class Conference extends AbstractConference<Props, *> {
  87. _onFullScreenChange: Function;
  88. _onShowToolbar: Function;
  89. _originalOnShowToolbar: Function;
  90. /**
  91. * Initializes a new Conference instance.
  92. *
  93. * @param {Object} props - The read-only properties with which the new
  94. * instance is to be initialized.
  95. */
  96. constructor(props) {
  97. super(props);
  98. // Throttle and bind this component's mousemove handler to prevent it
  99. // from firing too often.
  100. this._originalOnShowToolbar = this._onShowToolbar;
  101. this._onShowToolbar = _.throttle(
  102. () => this._originalOnShowToolbar(),
  103. 100,
  104. {
  105. leading: true,
  106. trailing: false
  107. });
  108. // Bind event handler so it is only bound once for every instance.
  109. this._onFullScreenChange = this._onFullScreenChange.bind(this);
  110. }
  111. /**
  112. * Start the connection and get the UI ready for the conference.
  113. *
  114. * @inheritdoc
  115. */
  116. componentDidMount() {
  117. document.title = `${this.props._roomName} | ${interfaceConfig.APP_NAME}`;
  118. this._start();
  119. }
  120. /**
  121. * Calls into legacy UI to update the application layout, if necessary.
  122. *
  123. * @inheritdoc
  124. * returns {void}
  125. */
  126. componentDidUpdate(prevProps) {
  127. if (this.props._shouldDisplayTileView
  128. === prevProps._shouldDisplayTileView) {
  129. return;
  130. }
  131. // TODO: For now VideoLayout is being called as LargeVideo and Filmstrip
  132. // sizing logic is still handled outside of React. Once all components
  133. // are in react they should calculate size on their own as much as
  134. // possible and pass down sizings.
  135. VideoLayout.refreshLayout();
  136. }
  137. /**
  138. * Disconnect from the conference when component will be
  139. * unmounted.
  140. *
  141. * @inheritdoc
  142. */
  143. componentWillUnmount() {
  144. APP.UI.unbindEvents();
  145. FULL_SCREEN_EVENTS.forEach(name =>
  146. document.removeEventListener(name, this._onFullScreenChange));
  147. APP.conference.isJoined() && this.props.dispatch(disconnect());
  148. }
  149. /**
  150. * Implements React's {@link Component#render()}.
  151. *
  152. * @inheritdoc
  153. * @returns {ReactElement}
  154. */
  155. render() {
  156. const {
  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 hideLabels = filmstripOnly || _iAmRecorder;
  167. return (
  168. <div
  169. className = { _layoutClassName }
  170. id = 'videoconference_page'
  171. onMouseMove = { this._onShowToolbar }>
  172. <Notice />
  173. <Subject />
  174. <InviteMore />
  175. <div id = 'videospace'>
  176. <LargeVideo />
  177. <KnockingParticipantList />
  178. { hideLabels || <Labels /> }
  179. <Filmstrip filmstripOnly = { filmstripOnly } />
  180. </div>
  181. { filmstripOnly || _showPrejoin || <Toolbox /> }
  182. { filmstripOnly || <Chat /> }
  183. { this.renderNotificationsContainer() }
  184. { !filmstripOnly && _showPrejoin && <Prejoin />}
  185. <CalleeInfoContainer />
  186. </div>
  187. );
  188. }
  189. /**
  190. * Updates the Redux state when full screen mode has been enabled or
  191. * disabled.
  192. *
  193. * @private
  194. * @returns {void}
  195. */
  196. _onFullScreenChange() {
  197. this.props.dispatch(fullScreenChanged(APP.UI.isFullScreen()));
  198. }
  199. /**
  200. * Displays the toolbar.
  201. *
  202. * @private
  203. * @returns {void}
  204. */
  205. _onShowToolbar() {
  206. this.props.dispatch(showToolbox());
  207. }
  208. /**
  209. * Until we don't rewrite UI using react components
  210. * we use UI.start from old app. Also method translates
  211. * component right after it has been mounted.
  212. *
  213. * @inheritdoc
  214. */
  215. _start() {
  216. APP.UI.start();
  217. APP.UI.registerListeners();
  218. APP.UI.bindEvents();
  219. FULL_SCREEN_EVENTS.forEach(name =>
  220. document.addEventListener(name, this._onFullScreenChange));
  221. const { dispatch, t } = this.props;
  222. dispatch(connect());
  223. maybeShowSuboptimalExperienceNotification(dispatch, t);
  224. interfaceConfig.filmStripOnly
  225. && dispatch(setToolboxAlwaysVisible(true));
  226. }
  227. }
  228. /**
  229. * Maps (parts of) the Redux state to the associated props for the
  230. * {@code Conference} component.
  231. *
  232. * @param {Object} state - The Redux state.
  233. * @private
  234. * @returns {Props}
  235. */
  236. function _mapStateToProps(state) {
  237. return {
  238. ...abstractMapStateToProps(state),
  239. _iAmRecorder: state['features/base/config'].iAmRecorder,
  240. _layoutClassName: LAYOUT_CLASSNAMES[getCurrentLayout(state)],
  241. _roomName: getConferenceNameForTitle(state),
  242. _showPrejoin: isPrejoinPageVisible(state)
  243. };
  244. }
  245. export default reactReduxConnect(_mapStateToProps)(translate(Conference));