您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // @flow
  2. import { getDefaultURL } from '../../app';
  3. import { APP_WILL_MOUNT } from '../app';
  4. import { SET_ROOM } from '../conference';
  5. import { MiddlewareRegistry } from '../redux';
  6. import { parseURIString } from '../util';
  7. import { addKnownDomains } from './actions';
  8. MiddlewareRegistry.register(store => next => action => {
  9. const result = next(action);
  10. switch (action.type) {
  11. case APP_WILL_MOUNT:
  12. _appWillMount(store);
  13. break;
  14. case SET_ROOM:
  15. _setRoom(store);
  16. break;
  17. }
  18. return result;
  19. });
  20. /**
  21. * Adds the domain of the app's {@code defaultURL} to the list of domains known
  22. * to the feature base/known-domains.
  23. *
  24. * @param {Object} store - The redux store.
  25. * @private
  26. * @returns {Promise}
  27. */
  28. function _appWillMount({ dispatch, getState }) {
  29. const defaultURL = parseURIString(getDefaultURL(getState));
  30. dispatch(addKnownDomains(defaultURL.host));
  31. }
  32. /**
  33. * Adds the domain of {@code locationURL} to the list of domains known to the
  34. * feature base/known-domains.
  35. *
  36. * @param {Object} store - The redux store.
  37. * @private
  38. * @returns {Promise}
  39. */
  40. function _setRoom({ dispatch, getState }) {
  41. const { locationURL } = getState()['features/base/connection'];
  42. let host;
  43. locationURL
  44. && (host = locationURL.host)
  45. && dispatch(addKnownDomains(host));
  46. }