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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // @flow
  2. import { appNavigate } from '../app';
  3. import { SET_WEBRTC_READY } from '../base/lib-jitsi-meet';
  4. import { MiddlewareRegistry } from '../base/redux';
  5. /**
  6. * Middleware that dispatches appNavigate when WebRTC readiness changes.
  7. *
  8. * @param {Store} store - The Redux store.
  9. * @returns {Function}
  10. * @private
  11. */
  12. MiddlewareRegistry.register(store => next => action => {
  13. switch (action.type) {
  14. case SET_WEBRTC_READY:
  15. return _setWebRTCReady(store, next, action);
  16. }
  17. return next(action);
  18. });
  19. /**
  20. * Notifies the feature unsupported-browser that the action SET_WEBRTC_READY is
  21. * being dispatched within a specific Redux store.
  22. *
  23. * @param {Store} store - The Redux store in which the specified action is being
  24. * dispatched.
  25. * @param {Dispatch} next - The Redux dispatch function to dispatch the
  26. * specified action to the specified store.
  27. * @param {Action} action - The Redux action SET_WEBRTC_READY which is being
  28. * dispatched in the specified store.
  29. * @private
  30. * @returns {Object} The new state that is the result of the reduction of the
  31. * specified action.
  32. */
  33. function _setWebRTCReady({ dispatch, getState }, next, action) {
  34. const result = next(action);
  35. // FIXME The feature unsupported-browser needs to notify the app that it may
  36. // need to render a different Component at its current location because the
  37. // execution enviroment has changed. The current location is not necessarily
  38. // available through window.location (e.g. on mobile) but the following
  39. // works at the time of this writing.
  40. const windowLocation = getState()['features/app'].app.getWindowLocation();
  41. if (windowLocation) {
  42. const { href } = windowLocation;
  43. href && dispatch(appNavigate(href));
  44. }
  45. return result;
  46. }