2022-10-07 08:39:18 +00:00
|
|
|
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
|
|
|
|
2022-10-07 08:39:18 +00:00
|
|
|
// @ts-ignore
|
2019-06-14 20:40:40 +00:00
|
|
|
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);
|
|
|
|
});
|