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 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {
  2. CONNECTION_ESTABLISHED,
  3. getURLWithoutParams
  4. } from '../base/connection';
  5. import { MiddlewareRegistry } from '../base/redux';
  6. MiddlewareRegistry.register(store => next => action => {
  7. switch (action.type) {
  8. case CONNECTION_ESTABLISHED:
  9. return _connectionEstablished(store, next, action);
  10. }
  11. return next(action);
  12. });
  13. /**
  14. * Notifies the feature app that the action {@link CONNECTION_ESTABLISHED} is
  15. * being dispatched within a specific Redux {@code store}.
  16. *
  17. * @param {Store} store - The Redux store in which the specified {@code action}
  18. * is being dispatched.
  19. * @param {Dispatch} next - The Redux {@code dispatch} function to dispatch the
  20. * specified {@code action} to the specified {@code store}.
  21. * @param {Action} action - The Redux action {@code CONNECTION_ESTABLISHED}
  22. * which is being dispatched in the specified {@code store}.
  23. * @private
  24. * @returns {Object} The new state that is the result of the reduction of the
  25. * specified {@code action}.
  26. */
  27. function _connectionEstablished(store, next, action) {
  28. const result = next(action);
  29. // In the Web app we explicitly do not want to display the hash and
  30. // query/search URL params. Unfortunately, window.location and, more
  31. // importantly, its params are used not only in jitsi-meet but also in
  32. // lib-jitsi-meet. Consequenlty, the time to remove the params is
  33. // determined by when no one needs them anymore.
  34. const { history, location } = window;
  35. if (history
  36. && location
  37. && history.length
  38. && typeof history.replaceState === 'function') {
  39. const replacement = getURLWithoutParams(location);
  40. if (location !== replacement) {
  41. history.replaceState(
  42. history.state,
  43. (document && document.title) || '',
  44. replacement);
  45. }
  46. }
  47. return result;
  48. }