ref(conference): move mousemove handler to react

This commit is contained in:
Leonard Kim 2017-10-10 22:45:20 -07:00 committed by yanas
parent 90451a640c
commit 323d38ac94
2 changed files with 38 additions and 12 deletions

View File

@ -4,8 +4,6 @@ const logger = require("jitsi-meet-logger").getLogger(__filename);
var UI = {}; var UI = {};
import _ from 'lodash';
import Chat from "./side_pannels/chat/Chat"; import Chat from "./side_pannels/chat/Chat";
import SidePanels from "./side_pannels/SidePanels"; import SidePanels from "./side_pannels/SidePanels";
import Avatar from "./avatar/Avatar"; import Avatar from "./avatar/Avatar";
@ -273,14 +271,6 @@ UI.start = function () {
sharedVideoManager = new SharedVideoManager(eventEmitter); sharedVideoManager = new SharedVideoManager(eventEmitter);
if (!interfaceConfig.filmStripOnly) { if (!interfaceConfig.filmStripOnly) {
let throttledShowToolbar
= _.throttle(
() => UI.showToolbar(),
100,
{ leading: true, trailing: false });
$("#videoconference_page").mousemove(throttledShowToolbar);
// Initialise the recording module. // Initialise the recording module.
if (config.enableRecording) { if (config.enableRecording) {
Recording.init(eventEmitter, config.recordingType); Recording.init(eventEmitter, config.recordingType);

View File

@ -1,5 +1,6 @@
/* @flow */ /* @flow */
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect as reactReduxConnect } from 'react-redux'; import { connect as reactReduxConnect } from 'react-redux';
@ -10,7 +11,7 @@ import { Filmstrip } from '../../filmstrip';
import { LargeVideo } from '../../large-video'; import { LargeVideo } from '../../large-video';
import { NotificationsContainer } from '../../notifications'; import { NotificationsContainer } from '../../notifications';
import { OverlayContainer } from '../../overlay'; import { OverlayContainer } from '../../overlay';
import { Toolbox } from '../../toolbox'; import { showToolbox, Toolbox } from '../../toolbox';
import { HideNotificationBarStyle } from '../../unsupported-browser'; import { HideNotificationBarStyle } from '../../unsupported-browser';
declare var $: Function; declare var $: Function;
@ -21,6 +22,8 @@ declare var interfaceConfig: Object;
* The conference page of the Web application. * The conference page of the Web application.
*/ */
class Conference extends Component { class Conference extends Component {
_onShowToolbar: Function;
_originalOnShowToolbar: Function;
/** /**
* Conference component's property types. * Conference component's property types.
@ -31,6 +34,27 @@ class Conference extends Component {
dispatch: PropTypes.func dispatch: PropTypes.func
}; };
/**
* Initializes a new Conference instance.
*
* @param {Object} props - The read-only properties with which the new
* instance is to be initialized.
*/
constructor(props) {
super(props);
// Throttle and bind this component's mousemove handler to prevent it
// from firing too often.
this._originalOnShowToolbar = this._onShowToolbar;
this._onShowToolbar = _.throttle(
() => this._originalOnShowToolbar(),
100,
{
leading: true,
trailing: false
});
}
/** /**
* Until we don't rewrite UI using react components * Until we don't rewrite UI using react components
* we use UI.start from old app. Also method translates * we use UI.start from old app. Also method translates
@ -71,7 +95,9 @@ class Conference extends Component {
const { filmStripOnly } = interfaceConfig; const { filmStripOnly } = interfaceConfig;
return ( return (
<div id = 'videoconference_page'> <div
id = 'videoconference_page'
onMouseMove = { this._onShowToolbar }>
<div id = 'videospace'> <div id = 'videospace'>
<LargeVideo /> <LargeVideo />
<Filmstrip filmstripOnly = { filmStripOnly } /> <Filmstrip filmstripOnly = { filmStripOnly } />
@ -94,6 +120,16 @@ class Conference extends Component {
</div> </div>
); );
} }
/**
* Displays the toolbar.
*
* @private
* @returns {void}
*/
_onShowToolbar() {
this.props.dispatch(showToolbox());
}
} }
export default reactReduxConnect()(Conference); export default reactReduxConnect()(Conference);