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.web.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
  3. import UIEvents from '../../../service/UI/UIEvents';
  4. import {
  5. DOMINANT_SPEAKER_CHANGED,
  6. PARTICIPANT_LEFT,
  7. PARTICIPANT_UPDATED,
  8. PIN_PARTICIPANT
  9. } from '../base/participants';
  10. import { MiddlewareRegistry } from '../base/redux';
  11. declare var APP: Object;
  12. /**
  13. * Middleware which intercepts actions and updates the legacy component
  14. * {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
  15. * {@code VideoLayout} without having to simultaneously react-ifying it.
  16. *
  17. * @param {Store} store - The redux store.
  18. * @returns {Function}
  19. */
  20. // eslint-disable-next-line no-unused-vars
  21. MiddlewareRegistry.register(store => next => action => {
  22. // Purposefully perform additional actions after state update to mimic
  23. // being connected to the store for updates.
  24. const result = next(action);
  25. switch (action.type) {
  26. case PARTICIPANT_LEFT:
  27. VideoLayout.removeParticipantContainer(action.participant.id);
  28. break;
  29. case PARTICIPANT_UPDATED: {
  30. // Look for actions that triggered a change to connectionStatus. This is
  31. // done instead of changing the connection status change action to be
  32. // explicit in order to minimize changes to other code.
  33. if (typeof action.participant.connectionStatus !== 'undefined') {
  34. VideoLayout.onParticipantConnectionStatusChanged(
  35. action.participant.id);
  36. }
  37. break;
  38. }
  39. case DOMINANT_SPEAKER_CHANGED:
  40. VideoLayout.onDominantSpeakerChanged(action.participant.id);
  41. break;
  42. case PIN_PARTICIPANT:
  43. VideoLayout.onPinChange(action.participant.id);
  44. APP.UI.emitEvent(
  45. UIEvents.PINNED_ENDPOINT,
  46. action.participant.id,
  47. Boolean(action.participant.id));
  48. break;
  49. }
  50. return result;
  51. });