fix(display-name): dismiss prompt if name gets set
This commit is contained in:
parent
1197c26529
commit
2f7f9f24c4
|
@ -1,4 +1,5 @@
|
||||||
export * from './actions';
|
export * from './actions';
|
||||||
|
export * from './actionTypes';
|
||||||
export * from './constants';
|
export * from './constants';
|
||||||
export * from './functions';
|
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
|
* @param {Function} onPostSubmit - The function to invoke after a
|
||||||
* succesfulsetting of the display name.
|
* succesfulsetting of the display name.
|
||||||
|
|
|
@ -3,3 +3,5 @@
|
||||||
export * from './actions';
|
export * from './actions';
|
||||||
export * from './components';
|
export * from './components';
|
||||||
export * from './functions';
|
export * from './functions';
|
||||||
|
|
||||||
|
import './middleware';
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
Loading…
Reference in New Issue