2017-06-05 18:19:25 +00:00
|
|
|
/* @flow */
|
2017-05-23 18:58:07 +00:00
|
|
|
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2017-06-05 18:19:25 +00:00
|
|
|
import { SET_CALL_OVERLAY_VISIBLE } from '../jwt';
|
|
|
|
|
|
|
|
import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
|
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
2017-05-23 18:58:07 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
SET_FILMSTRIP_REMOTE_VIDEOS_VISIBLITY,
|
|
|
|
SET_FILMSTRIP_VISIBILITY
|
|
|
|
} from './actionTypes';
|
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
2017-06-05 18:19:25 +00:00
|
|
|
MiddlewareRegistry.register(({ getState }) => next => action => {
|
2017-05-23 18:58:07 +00:00
|
|
|
switch (action.type) {
|
2017-06-05 18:19:25 +00:00
|
|
|
case SET_CALL_OVERLAY_VISIBLE:
|
2017-06-10 22:47:37 +00:00
|
|
|
if (typeof APP !== 'undefined') {
|
2017-06-05 18:19:25 +00:00
|
|
|
const oldValue
|
|
|
|
= Boolean(getState()['features/jwt'].callOverlayVisible);
|
|
|
|
const result = next(action);
|
|
|
|
const newValue
|
|
|
|
= Boolean(getState()['features/jwt'].callOverlayVisible);
|
2017-05-23 18:58:07 +00:00
|
|
|
|
2017-06-05 18:19:25 +00:00
|
|
|
oldValue === newValue
|
2017-06-10 22:47:37 +00:00
|
|
|
|
|
|
|
// FIXME The following accesses the private state filmstrip of
|
|
|
|
// Filmstrip. It is written with the understanding that
|
|
|
|
// Filmstrip will be rewritten in React and, consequently, will
|
|
|
|
// not need the middleware implemented here, Filmstrip.init, and
|
|
|
|
// UI.start.
|
|
|
|
|| (Filmstrip.filmstrip
|
|
|
|
&& Filmstrip.toggleFilmstrip(!newValue, false));
|
2017-06-05 18:19:25 +00:00
|
|
|
|
|
|
|
return result;
|
2017-05-23 18:58:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-06-05 18:19:25 +00:00
|
|
|
|
|
|
|
case SET_FILMSTRIP_REMOTE_VIDEOS_VISIBLITY:
|
|
|
|
case SET_FILMSTRIP_VISIBILITY: {
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
typeof APP === 'undefined'
|
|
|
|
|| APP.UI.emitEvent(UIEvents.UPDATED_FILMSTRIP_DISPLAY);
|
|
|
|
|
|
|
|
return result;
|
2017-05-23 18:58:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 18:19:25 +00:00
|
|
|
return next(action);
|
2017-05-23 18:58:07 +00:00
|
|
|
});
|