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

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