You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.js 709B

1234567891011121314151617181920212223242526
  1. // @flow
  2. import { hideDialog, isDialogOpen } from '../base/dialog';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { SETTINGS_UPDATED } from '../base/settings';
  5. import { DisplayNamePrompt } from './components';
  6. /**
  7. * Middleware that captures actions related to display name setting.
  8. *
  9. * @param {Store} store - The redux store.
  10. * @returns {Function}
  11. */
  12. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  13. switch (action.type) {
  14. case SETTINGS_UPDATED: {
  15. if (action.settings.displayName
  16. && isDialogOpen(getState, DisplayNamePrompt)) {
  17. dispatch(hideDialog(DisplayNamePrompt));
  18. }
  19. }
  20. }
  21. return next(action);
  22. });