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-02-26 16:14:46 +00:00
|
|
|
import { setSettingsViewVisible } from './actions';
|
2018-01-18 21:28:25 +00:00
|
|
|
|
2018-01-08 11:00:31 +00:00
|
|
|
/**
|
2018-02-26 16:14:46 +00:00
|
|
|
* The redux middleware to set the visibility of {@link SettingsView}.
|
2018-01-08 11:00:31 +00:00
|
|
|
*
|
2018-02-26 16:14:46 +00:00
|
|
|
* @param {Store} store - The redux store.
|
2018-01-08 11:00:31 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
switch (action.type) {
|
|
|
|
case SET_ROOM:
|
2018-02-26 16:14:46 +00:00
|
|
|
return _hideSettingsView(store, next, action);
|
2018-01-08 11:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2018-02-26 16:14:46 +00:00
|
|
|
* Hides {@link SettingsView}.
|
2018-01-08 11:00:31 +00:00
|
|
|
*
|
|
|
|
* @param {Store} store - The redux store.
|
2018-02-26 16:14:46 +00:00
|
|
|
* @param {Dispatch} next - The redux {@code dispatch} function.
|
2018-01-08 11:00:31 +00:00
|
|
|
* @param {Action} action - The redux action.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state.
|
|
|
|
*/
|
2018-02-26 16:14:46 +00:00
|
|
|
function _hideSettingsView({ dispatch }, next, action) {
|
|
|
|
dispatch(setSettingsViewVisible(false));
|
2018-01-08 11:00:31 +00:00
|
|
|
|
|
|
|
return next(action);
|
|
|
|
}
|