選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

middleware.web.js 1.5KB

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