Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

middleware.web.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // @flow
  2. import { hideDialog, openDialog } from '../base/dialog';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { BEGIN_ADD_PEOPLE, HIDE_ADD_PEOPLE_DIALOG } from './actionTypes';
  5. import { AddPeopleDialog } from './components';
  6. import './middleware.any';
  7. /**
  8. * The middleware of the feature invite specific to Web/React.
  9. *
  10. * @param {Store} store - The redux store.
  11. * @returns {Function}
  12. */
  13. MiddlewareRegistry.register(store => next => action => {
  14. switch (action.type) {
  15. case BEGIN_ADD_PEOPLE:
  16. return _beginAddPeople(store, next, action);
  17. case HIDE_ADD_PEOPLE_DIALOG:
  18. return _hideAddPeopleDialog(store, next, action);
  19. }
  20. return next(action);
  21. });
  22. /**
  23. * Notifies the feature invite that the action {@link BEGIN_ADD_PEOPLE} is being
  24. * dispatched within a specific redux {@code store}.
  25. *
  26. * @param {Store} store - The redux store in which the specified {@code action}
  27. * is being dispatched.
  28. * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
  29. * specified {@code action} to the specified {@code store}.
  30. * @param {Action} action - The redux action {@code BEGIN_ADD_PEOPLE} which is
  31. * being dispatched in the specified {@code store}.
  32. * @private
  33. * @returns {*} The value returned by {@code next(action)}.
  34. */
  35. function _beginAddPeople({ dispatch }, next, action) {
  36. const result = next(action);
  37. dispatch(openDialog(AddPeopleDialog));
  38. return result;
  39. }
  40. /**
  41. * Notifies the feature invite that the action {@link HIDE_ADD_PEOPLE_DIALOG} is being
  42. * dispatched within a specific redux {@code store}.
  43. *
  44. * @param {Store} store - The redux store in which the specified {@code action}
  45. * is being dispatched.
  46. * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
  47. * specified {@code action} to the specified {@code store}.
  48. * @param {Action} action - The redux action {@code HIDE_ADD_PEOPLE_DIALOG} which is
  49. * being dispatched in the specified {@code store}.
  50. * @private
  51. * @returns {*} The value returned by {@code next(action)}.
  52. */
  53. function _hideAddPeopleDialog({ dispatch }, next, action) {
  54. dispatch(hideDialog(AddPeopleDialog));
  55. return next(action);
  56. }