2018-02-01 14:22:27 +00:00
|
|
|
// @flow
|
2017-05-23 18:58:07 +00:00
|
|
|
|
2018-02-01 14:22:27 +00:00
|
|
|
import { setLastN } from '../base/conference';
|
2017-11-23 16:26:47 +00:00
|
|
|
import { SET_CALLEE_INFO_VISIBLE } from '../base/jwt';
|
2018-02-01 14:22:27 +00:00
|
|
|
import { pinParticipant } from '../base/participants';
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
2017-06-05 18:19:25 +00:00
|
|
|
|
|
|
|
import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
|
2017-05-23 18:58:07 +00:00
|
|
|
|
2018-02-01 14:22:27 +00:00
|
|
|
import { SET_FILMSTRIP_ENABLED } from './actionTypes';
|
|
|
|
|
2017-05-23 18:58:07 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
|
2018-02-01 14:22:27 +00:00
|
|
|
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
2017-05-23 18:58:07 +00:00
|
|
|
switch (action.type) {
|
2017-11-23 16:26:47 +00:00
|
|
|
case SET_CALLEE_INFO_VISIBLE:
|
2017-06-10 22:47:37 +00:00
|
|
|
if (typeof APP !== 'undefined') {
|
2017-06-05 18:19:25 +00:00
|
|
|
const oldValue
|
2017-11-23 16:26:47 +00:00
|
|
|
= Boolean(getState()['features/base/jwt'].calleeInfoVisible);
|
2017-06-05 18:19:25 +00:00
|
|
|
const result = next(action);
|
|
|
|
const newValue
|
2017-11-23 16:26:47 +00:00
|
|
|
= Boolean(getState()['features/base/jwt'].calleeInfoVisible);
|
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
|
2018-01-03 21:24:07 +00:00
|
|
|
&& Filmstrip.toggleFilmstrip(!newValue));
|
2017-06-05 18:19:25 +00:00
|
|
|
|
|
|
|
return result;
|
2017-05-23 18:58:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-02-01 14:22:27 +00:00
|
|
|
|
|
|
|
case SET_FILMSTRIP_ENABLED:
|
|
|
|
// FIXME: Only do this on mobile for now. The logic for participant
|
|
|
|
// pinning / unpinning is not on React yet so dispatching the action
|
|
|
|
// is not enough.
|
|
|
|
if (typeof APP === 'undefined') {
|
|
|
|
const { audioOnly } = getState()['features/base/conference'];
|
|
|
|
const { enabled } = action;
|
|
|
|
|
|
|
|
!enabled && dispatch(pinParticipant(null));
|
|
|
|
!audioOnly && dispatch(setLastN(enabled ? undefined : 1));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
});
|