fix(display-name): dismiss prompt if name gets set

This commit is contained in:
Leonard Kim
2019-06-17 15:10:53 +01:00
committed by yanas
parent 1197c26529
commit 2f7f9f24c4
4 changed files with 29 additions and 1 deletions
+1
View File
@@ -1,4 +1,5 @@
export * from './actions';
export * from './actionTypes';
export * from './constants';
export * from './functions';
@@ -96,7 +96,7 @@ function _mapDispatchToProps(dispatch: Function) {
},
/**
* Displays a diaply name prompt.
* Displays a display name prompt.
*
* @param {Function} onPostSubmit - The function to invoke after a
* succesfulsetting of the display name.
+2
View File
@@ -3,3 +3,5 @@
export * from './actions';
export * from './components';
export * from './functions';
import './middleware';
+25
View File
@@ -0,0 +1,25 @@
// @flow
import { hideDialog, isDialogOpen } from '../base/dialog';
import { MiddlewareRegistry } from '../base/redux';
import { SETTINGS_UPDATED } from '../base/settings';
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);
});