2018-03-07 00:28:19 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { MiddlewareRegistry } from '../base/redux';
|
|
|
|
|
2018-06-20 20:19:53 +00:00
|
|
|
import { CLOSE_PANEL, TOGGLE_CHAT } from './actionTypes';
|
2018-03-07 00:28:19 +00:00
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Middleware that catches actions related to the non-reactified web side panel.
|
|
|
|
*
|
|
|
|
* @param {Store} store - Redux store.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
|
|
if (typeof APP !== 'object') {
|
|
|
|
return next(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (action.type) {
|
|
|
|
case CLOSE_PANEL:
|
|
|
|
APP.UI.toggleSidePanel(action.current);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOGGLE_CHAT:
|
|
|
|
APP.UI.toggleChat();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|