2017-05-24 17:01:46 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
import _ from 'lodash';
|
2017-05-24 17:01:46 +00:00
|
|
|
import React, { Component } from 'react';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
import {
|
|
|
|
createShortcutEvent,
|
|
|
|
createToolbarEvent,
|
|
|
|
sendAnalytics
|
|
|
|
} from '../../../analytics';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { dockToolbox } from '../../../toolbox';
|
2017-07-06 02:07:00 +00:00
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
import { setFilmstripHovered, setFilmstripVisible } from '../../actions';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { shouldRemoteVideosBeVisible } from '../../functions';
|
2018-08-08 18:48:23 +00:00
|
|
|
|
2018-04-18 10:15:37 +00:00
|
|
|
import Toolbar from './Toolbar';
|
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
declare var APP: Object;
|
2018-03-07 00:28:19 +00:00
|
|
|
declare var interfaceConfig: Object;
|
|
|
|
|
2018-06-25 15:33:08 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link Filmstrip}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional CSS class names top add to the root.
|
|
|
|
*/
|
|
|
|
_className: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the UI/UX is filmstrip-only.
|
|
|
|
*/
|
|
|
|
_filmstripOnly: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not remote videos are currently being hovered over. Hover
|
|
|
|
* handling is currently being handled detected outside of react.
|
|
|
|
*/
|
|
|
|
_hovered: boolean,
|
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
/**
|
|
|
|
* Additional CSS class names to add to the container of all the thumbnails.
|
|
|
|
*/
|
|
|
|
_videosClassName: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the filmstrip videos should currently be displayed.
|
|
|
|
*/
|
|
|
|
_visible: boolean,
|
|
|
|
|
2018-06-25 15:33:08 +00:00
|
|
|
/**
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>
|
2018-06-25 15:33:08 +00:00
|
|
|
};
|
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
/**
|
|
|
|
* Implements a React {@link Component} which represents the filmstrip on
|
|
|
|
* Web/React.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2018-06-25 15:33:08 +00:00
|
|
|
class Filmstrip extends Component <Props> {
|
2017-09-01 21:40:05 +00:00
|
|
|
_isHovered: boolean;
|
|
|
|
|
|
|
|
_notifyOfHoveredStateUpdate: Function;
|
|
|
|
|
|
|
|
_onMouseOut: Function;
|
|
|
|
|
|
|
|
_onMouseOver: Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new {@code Filmstrip} instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only properties with which the new
|
|
|
|
* instance is to be initialized.
|
|
|
|
*/
|
2018-06-25 15:33:08 +00:00
|
|
|
constructor(props: Props) {
|
2017-09-01 21:40:05 +00:00
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Debounce the method for dispatching the new filmstrip handled state
|
|
|
|
// so that it does not get called with each mouse movement event. This
|
|
|
|
// also works around an issue where mouseout and then a mouseover event
|
|
|
|
// is fired when hovering over remote thumbnails, which are not yet in
|
|
|
|
// react.
|
|
|
|
this._notifyOfHoveredStateUpdate
|
|
|
|
= _.debounce(this._notifyOfHoveredStateUpdate, 100);
|
|
|
|
|
|
|
|
// Cache the current hovered state for _updateHoveredState to always
|
|
|
|
// send the last known hovered state.
|
|
|
|
this._isHovered = false;
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onMouseOut = this._onMouseOut.bind(this);
|
2018-05-03 17:36:29 +00:00
|
|
|
this._onMouseOver = this._onMouseOver.bind(this);
|
2018-09-10 22:10:45 +00:00
|
|
|
this._onShortcutToggleFilmstrip
|
|
|
|
= this._onShortcutToggleFilmstrip.bind(this);
|
|
|
|
this._onToolbarToggleFilmstrip
|
|
|
|
= this._onToolbarToggleFilmstrip.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#componentDidMount}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
|
|
|
if (!this.props._filmstripOnly) {
|
|
|
|
APP.keyboardshortcut.registerShortcut(
|
|
|
|
'F',
|
|
|
|
'filmstripPopover',
|
|
|
|
this._onShortcutToggleFilmstrip,
|
|
|
|
'keyboardShortcuts.toggleFilmstrip'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#componentDidUpdate}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
APP.keyboardshortcut.unregisterShortcut('F');
|
2017-09-01 21:40:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-05-03 17:36:29 +00:00
|
|
|
// Note: Appending of {@code RemoteVideo} views is handled through
|
|
|
|
// VideoLayout. The views do not get blown away on render() because
|
|
|
|
// ReactDOMComponent is only aware of the given JSX and not new appended
|
|
|
|
// DOM. As such, when updateDOMProperties gets called, only attributes
|
|
|
|
// will get updated without replacing the DOM. If the known DOM gets
|
|
|
|
// modified, then the views will get blown away.
|
2017-08-12 00:27:30 +00:00
|
|
|
|
2017-05-24 17:01:46 +00:00
|
|
|
return (
|
2018-06-25 15:33:08 +00:00
|
|
|
<div className = { `filmstrip ${this.props._className}` }>
|
2018-09-10 22:10:45 +00:00
|
|
|
{ this.props._filmstripOnly
|
|
|
|
? <Toolbar /> : this._renderToggleButton() }
|
2017-05-24 17:01:46 +00:00
|
|
|
<div
|
2018-09-10 22:10:45 +00:00
|
|
|
className = { this.props._videosClassName }
|
2017-05-24 17:01:46 +00:00
|
|
|
id = 'remoteVideos'>
|
|
|
|
<div
|
|
|
|
className = 'filmstrip__videos'
|
2017-09-01 21:40:05 +00:00
|
|
|
id = 'filmstripLocalVideo'
|
|
|
|
onMouseOut = { this._onMouseOut }
|
2017-10-03 16:30:42 +00:00
|
|
|
onMouseOver = { this._onMouseOver }>
|
2017-11-02 16:22:33 +00:00
|
|
|
<div id = 'filmstripLocalVideoThumbnail' />
|
2017-10-03 16:30:42 +00:00
|
|
|
</div>
|
2017-05-24 17:01:46 +00:00
|
|
|
<div
|
|
|
|
className = 'filmstrip__videos'
|
|
|
|
id = 'filmstripRemoteVideos'>
|
2018-05-03 17:36:29 +00:00
|
|
|
{/*
|
|
|
|
* XXX This extra video container is needed for
|
|
|
|
* scrolling thumbnails in Firefox; otherwise, the flex
|
2017-05-24 17:01:46 +00:00
|
|
|
* thumbnails resize instead of causing overflow.
|
|
|
|
*/}
|
|
|
|
<div
|
|
|
|
className = 'remote-videos-container'
|
2017-09-01 21:40:05 +00:00
|
|
|
id = 'filmstripRemoteVideosContainer'
|
|
|
|
onMouseOut = { this._onMouseOut }
|
2018-07-26 17:51:15 +00:00
|
|
|
onMouseOver = { this._onMouseOver }>
|
|
|
|
<div id = 'localVideoTileViewContainer' />
|
|
|
|
</div>
|
2017-05-24 17:01:46 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-09-01 21:40:05 +00:00
|
|
|
|
2018-09-10 22:10:45 +00:00
|
|
|
/**
|
|
|
|
* Dispatches an action to change the visibility of the filmstrip.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_doToggleFilmstrip() {
|
|
|
|
this.props.dispatch(setFilmstripVisible(!this.props._visible));
|
|
|
|
}
|
|
|
|
|
2017-09-01 21:40:05 +00:00
|
|
|
/**
|
|
|
|
* If the current hover state does not match the known hover state in redux,
|
|
|
|
* dispatch an action to update the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_notifyOfHoveredStateUpdate() {
|
|
|
|
if (this.props._hovered !== this._isHovered) {
|
2018-04-09 05:03:26 +00:00
|
|
|
this.props.dispatch(dockToolbox(this._isHovered));
|
2017-09-01 21:40:05 +00:00
|
|
|
this.props.dispatch(setFilmstripHovered(this._isHovered));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the currently known mouseover state and attempt to dispatch an
|
|
|
|
* update of the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseOut() {
|
|
|
|
this._isHovered = false;
|
|
|
|
this._notifyOfHoveredStateUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the currently known mouseover state and attempt to dispatch an
|
|
|
|
* update of the known hover state in redux.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onMouseOver() {
|
|
|
|
this._isHovered = true;
|
|
|
|
this._notifyOfHoveredStateUpdate();
|
|
|
|
}
|
2018-09-10 22:10:45 +00:00
|
|
|
|
|
|
|
_onShortcutToggleFilmstrip: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an analytics keyboard shortcut event and dispatches an action for
|
|
|
|
* toggling filmstrip visibility.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onShortcutToggleFilmstrip() {
|
|
|
|
sendAnalytics(createShortcutEvent(
|
|
|
|
'toggle.filmstrip',
|
|
|
|
{
|
|
|
|
enable: this.props._visible
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._doToggleFilmstrip();
|
|
|
|
}
|
|
|
|
|
|
|
|
_onToolbarToggleFilmstrip: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an analytics toolbar event and dispatches an action for opening
|
|
|
|
* the speaker stats modal.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onToolbarToggleFilmstrip() {
|
|
|
|
sendAnalytics(createToolbarEvent(
|
|
|
|
'toggle.filmstrip.button',
|
|
|
|
{
|
|
|
|
enable: this.props._visible
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._doToggleFilmstrip();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a React Element for changing the visibility of the filmstrip when
|
|
|
|
* clicked.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderToggleButton() {
|
|
|
|
const icon = this.props._visible ? 'icon-menu-down' : 'icon-menu-up';
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = 'filmstrip__toolbar'>
|
|
|
|
<button
|
|
|
|
id = 'toggleFilmstripButton'
|
|
|
|
onClick = { this._onToolbarToggleFilmstrip }>
|
|
|
|
<i className = { icon } />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-05-24 17:01:46 +00:00
|
|
|
}
|
2017-08-12 00:27:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated {@code Filmstrip}'s props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {{
|
2018-06-25 15:33:08 +00:00
|
|
|
* _className: string,
|
2018-09-10 22:10:45 +00:00
|
|
|
* _filmstripOnly: boolean,
|
2018-03-12 19:23:40 +00:00
|
|
|
* _hovered: boolean,
|
2018-09-10 22:10:45 +00:00
|
|
|
* _videosClassName: string,
|
|
|
|
* _visible: boolean
|
2017-08-12 00:27:30 +00:00
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
2018-09-10 22:10:45 +00:00
|
|
|
const { hovered, visible } = state['features/filmstrip'];
|
2018-06-25 15:33:08 +00:00
|
|
|
const isFilmstripOnly = Boolean(interfaceConfig.filmStripOnly);
|
|
|
|
const reduceHeight = !isFilmstripOnly
|
|
|
|
&& state['features/toolbox'].visible
|
|
|
|
&& interfaceConfig.TOOLBAR_BUTTONS.length;
|
|
|
|
const remoteVideosVisible = shouldRemoteVideosBeVisible(state);
|
|
|
|
const className = `${remoteVideosVisible ? '' : 'hide-videos'} ${
|
2018-08-08 18:48:23 +00:00
|
|
|
reduceHeight ? 'reduce-height' : ''}`.trim();
|
2018-09-11 17:24:54 +00:00
|
|
|
const videosClassName = `filmstrip__videos${
|
|
|
|
isFilmstripOnly ? ' filmstrip__videos-filmstripOnly' : ''}${
|
|
|
|
visible ? '' : ' hidden'}`;
|
2018-03-12 19:23:40 +00:00
|
|
|
|
2017-08-12 00:27:30 +00:00
|
|
|
return {
|
2018-06-25 15:33:08 +00:00
|
|
|
_className: className,
|
|
|
|
_filmstripOnly: isFilmstripOnly,
|
2018-09-10 22:10:45 +00:00
|
|
|
_hovered: hovered,
|
|
|
|
_videosClassName: videosClassName,
|
|
|
|
_visible: visible
|
2017-08-12 00:27:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(Filmstrip);
|