jiti-meet/react/features/display-name/middleware.ts

27 lines
791 B
TypeScript
Raw Normal View History

import { hideDialog } from '../base/dialog/actions';
import { isDialogOpen } from '../base/dialog/functions';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { SETTINGS_UPDATED } from '../base/settings/actionTypes';
2020-05-20 10:57:03 +00:00
// @ts-ignore
import { DisplayNamePrompt } from './components';
/**
* Middleware that captures actions related to display name setting.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
switch (action.type) {
case SETTINGS_UPDATED: {
if (action.settings.displayName
&& isDialogOpen(getState, DisplayNamePrompt)) {
dispatch(hideDialog(DisplayNamePrompt));
}
}
}
return next(action);
});