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';
|
|
|
|
import { pinParticipant } from '../base/participants';
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
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-13 17:58:26 +00:00
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
2017-05-23 18:58:07 +00:00
|
|
|
switch (action.type) {
|
2018-02-01 14:22:27 +00:00
|
|
|
case SET_FILMSTRIP_ENABLED:
|
2018-02-13 17:58:26 +00:00
|
|
|
return _setFilmstripEnabled(store, next, action);
|
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
|
|
|
});
|
2018-02-13 17:58:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notifies the feature filmstrip that the action {@link SET_FILMSTRIP_ENABLED}
|
|
|
|
* is being dispatched within a specific redux store.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store in which the specified action is being
|
|
|
|
* dispatched.
|
|
|
|
* @param {Dispatch} next - The redux dispatch function to dispatch the
|
|
|
|
* specified action to the specified store.
|
|
|
|
* @param {Action} action - The redux action {@code SET_FILMSTRIP_ENABLED} which
|
|
|
|
* is being dispatched in the specified store.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The value returned by {@code next(action)}.
|
|
|
|
*/
|
|
|
|
function _setFilmstripEnabled({ dispatch, getState }, next, action) {
|
|
|
|
const result = next(action);
|
|
|
|
|
|
|
|
// FIXME The logic for participant pinning / unpinning is not on React yet
|
|
|
|
// so dispatching the action is not enough. Hence, perform the following
|
|
|
|
// only where it will be sufficient i.e. mobile.
|
|
|
|
if (typeof APP === 'undefined') {
|
|
|
|
const state = getState();
|
|
|
|
const { enabled } = state['features/filmstrip'];
|
|
|
|
const { audioOnly } = state['features/base/conference'];
|
|
|
|
|
|
|
|
enabled || dispatch(pinParticipant(null));
|
|
|
|
|
|
|
|
// FIXME Audio-only mode fiddles with lastN as well. That's why we don't
|
|
|
|
// touch lastN in audio-only mode. But it's not clear what the value of
|
|
|
|
// lastN should be upon exit from audio-only mode if the filmstrip is
|
|
|
|
// disabled already. Currently, audio-only mode will set undefined
|
|
|
|
// regardless of whether the filmstrip is disabled. But we don't have a
|
|
|
|
// practical use case in which audio-only mode is exited while the
|
|
|
|
// filmstrip is disabled.
|
|
|
|
audioOnly || dispatch(setLastN(enabled ? undefined : 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|