From 2f7f9f24c4f9fd63fdabeab5d701b28b46a8085e Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Fri, 14 Jun 2019 13:40:40 -0700 Subject: [PATCH] fix(display-name): dismiss prompt if name gets set --- react/features/base/settings/index.js | 1 + .../chat/components/native/ChatButton.js | 2 +- react/features/display-name/index.js | 2 ++ react/features/display-name/middleware.js | 25 +++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 react/features/display-name/middleware.js diff --git a/react/features/base/settings/index.js b/react/features/base/settings/index.js index 086f53a9e..39f1ee456 100644 --- a/react/features/base/settings/index.js +++ b/react/features/base/settings/index.js @@ -1,4 +1,5 @@ export * from './actions'; +export * from './actionTypes'; export * from './constants'; export * from './functions'; diff --git a/react/features/chat/components/native/ChatButton.js b/react/features/chat/components/native/ChatButton.js index 52fc70c80..2461d3127 100644 --- a/react/features/chat/components/native/ChatButton.js +++ b/react/features/chat/components/native/ChatButton.js @@ -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. diff --git a/react/features/display-name/index.js b/react/features/display-name/index.js index c13d3e017..46a00713e 100644 --- a/react/features/display-name/index.js +++ b/react/features/display-name/index.js @@ -3,3 +3,5 @@ export * from './actions'; export * from './components'; export * from './functions'; + +import './middleware'; diff --git a/react/features/display-name/middleware.js b/react/features/display-name/middleware.js new file mode 100644 index 000000000..652a7f33d --- /dev/null +++ b/react/features/display-name/middleware.js @@ -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); +});