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.

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