2018-01-18 21:28:25 +00:00
|
|
|
// @flow
|
2018-01-08 11:00:31 +00:00
|
|
|
|
|
|
|
import { SET_ROOM } from '../base/conference';
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
|
|
2018-01-18 21:28:25 +00:00
|
|
|
import { hideAppSettings } from './actions';
|
|
|
|
|
2018-01-08 11:00:31 +00:00
|
|
|
/**
|
|
|
|
* The Redux middleware to trigger settings screen show or hide
|
|
|
|
* when necessary.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The Redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
switch (action.type) {
|
|
|
|
case SET_ROOM:
|
|
|
|
return _closeAppSettings(store, next, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the settings screen.
|
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
|
|
|
* @param {Dispatch} next - The redux dispatch function.
|
|
|
|
* @param {Action} action - The redux action.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state.
|
|
|
|
*/
|
2018-01-18 21:28:25 +00:00
|
|
|
function _closeAppSettings({ dispatch }, next, action) {
|
|
|
|
dispatch(hideAppSettings());
|
2018-01-08 11:00:31 +00:00
|
|
|
|
|
|
|
return next(action);
|
|
|
|
}
|