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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. // @flow
  2. import _ from 'lodash';
  3. import React from 'react';
  4. import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout';
  5. import { connect, disconnect } from '../../../base/connection';
  6. import { translate } from '../../../base/i18n';
  7. import { connect as reactReduxConnect } from '../../../base/redux';
  8. import { getBackendSafeRoomName } from '../../../base/util';
  9. import { Chat } from '../../../chat';
  10. import { Filmstrip } from '../../../filmstrip';
  11. import { CalleeInfoContainer } from '../../../invite';
  12. import { LargeVideo } from '../../../large-video';
  13. import { LAYOUTS, getCurrentLayout } from '../../../video-layout';
  14. import {
  15. Toolbox,
  16. fullScreenChanged,
  17. setToolboxAlwaysVisible,
  18. showToolbox
  19. } from '../../../toolbox';
  20. import { maybeShowSuboptimalExperienceNotification } from '../../functions';
  21. import Labels from './Labels';
  22. import { default as Notice } from './Notice';
  23. import { default as Subject } from './Subject';
  24. import {
  25. AbstractConference,
  26. abstractMapStateToProps
  27. } from '../AbstractConference';
  28. import type { AbstractProps } from '../AbstractConference';
  29. import {DevHook} from '../../../../../rdev/hooks/Hooks';
  30. declare var APP: Object;
  31. declare var config: Object;
  32. declare var interfaceConfig: Object;
  33. /**
  34. * DOM events for when full screen mode has changed. Different browsers need
  35. * different vendor prefixes.
  36. *
  37. * @private
  38. * @type {Array<string>}
  39. */
  40. const FULL_SCREEN_EVENTS = [
  41. 'webkitfullscreenchange',
  42. 'mozfullscreenchange',
  43. 'fullscreenchange'
  44. ];
  45. /**
  46. * The CSS class to apply to the root element of the conference so CSS can
  47. * modify the app layout.
  48. *
  49. * @private
  50. * @type {Object}
  51. */
  52. const LAYOUT_CLASSNAMES = {
  53. [LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW]: 'horizontal-filmstrip',
  54. [LAYOUTS.TILE_VIEW]: 'tile-view',
  55. [LAYOUTS.VERTICAL_FILMSTRIP_VIEW]: 'vertical-filmstrip'
  56. };
  57. /**
  58. * The type of the React {@code Component} props of {@link Conference}.
  59. */
  60. type Props = AbstractProps & {
  61. /**
  62. * Whether the local participant is recording the conference.
  63. */
  64. _iAmRecorder: 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. dispatch: Function,
  75. t: Function
  76. }
  77. /**
  78. * The conference page of the Web application.
  79. */
  80. class Conference extends AbstractConference<Props, *> {
  81. _onFullScreenChange: Function;
  82. _onShowToolbar: Function;
  83. _originalOnShowToolbar: Function;
  84. /**
  85. * Initializes a new Conference instance.
  86. *
  87. * @param {Object} props - The read-only properties with which the new
  88. * instance is to be initialized.
  89. */
  90. constructor(props) {
  91. super(props);
  92. // dev hook
  93. window.glob_dev_hooks.react_conference = this
  94. window.glob_dev_hooks.react_conference_arr ? 0 : window.glob_dev_hooks.react_conference_arr = []
  95. window.glob_dev_hooks.react_conference_arr.push(this)
  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. VIDEO_QUALITY_LABEL_DISABLED,
  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 hideVideoQualityLabel
  161. = filmstripOnly
  162. || VIDEO_QUALITY_LABEL_DISABLED
  163. || this.props._iAmRecorder;
  164. // onMouseMove = { window.fn_mm }>
  165. // onMouseMove = { this._onShowToolbar }>
  166. return (
  167. <div
  168. className = { this.props._layoutClassName }
  169. id = 'videoconference_page'
  170. onMouseMove = { window.fn_mm ? window.fn_mm.bind(this) : this._onShowToolbar }>
  171. <Notice />
  172. <Subject />
  173. <DevHook type="div" className="top_toolbox jdiv"></DevHook>
  174. <div id = 'videospace'>
  175. <DevHook type="div" className="vspace jdiv"></DevHook>
  176. <LargeVideo />
  177. { hideVideoQualityLabel
  178. || <Labels /> }
  179. <Filmstrip filmstripOnly = { filmstripOnly } />
  180. </div>
  181. { filmstripOnly || <Toolbox /> }
  182. { filmstripOnly || <Chat /> }
  183. { this.renderNotificationsContainer() }
  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. /*
  206. try {
  207. var fn_name = "conference__onShowToolbar"
  208. var fn_ret = glob_dev_fns[fn_name]({that:this,kv:{ev},args:[...arguments],fn_name,arg0:arguments})
  209. if (fn_ret){ return fn_ret.ret };
  210. } catch (err) { clog(`react_fn fn_name:${fn_name} err:`,err) }
  211. */
  212. this.props.dispatch(showToolbox());
  213. }
  214. /**
  215. * Until we don't rewrite UI using react components
  216. * we use UI.start from old app. Also method translates
  217. * component right after it has been mounted.
  218. *
  219. * @inheritdoc
  220. */
  221. _start() {
  222. APP.UI.start();
  223. APP.UI.registerListeners();
  224. APP.UI.bindEvents();
  225. FULL_SCREEN_EVENTS.forEach(name =>
  226. document.addEventListener(name, this._onFullScreenChange));
  227. const { dispatch, t } = this.props;
  228. dispatch(connect());
  229. maybeShowSuboptimalExperienceNotification(dispatch, t);
  230. interfaceConfig.filmStripOnly
  231. && dispatch(setToolboxAlwaysVisible(true));
  232. }
  233. }
  234. /**
  235. * Maps (parts of) the Redux state to the associated props for the
  236. * {@code Conference} component.
  237. *
  238. * @param {Object} state - The Redux state.
  239. * @private
  240. * @returns {Props}
  241. */
  242. function _mapStateToProps(state) {
  243. const currentLayout = getCurrentLayout(state);
  244. const roomName = getBackendSafeRoomName(state['features/base/conference'].room);
  245. return {
  246. ...abstractMapStateToProps(state),
  247. _iAmRecorder: state['features/base/config'].iAmRecorder,
  248. _layoutClassName: LAYOUT_CLASSNAMES[currentLayout],
  249. _roomName: roomName
  250. };
  251. }
  252. export default reactReduxConnect(_mapStateToProps)(translate(Conference));