您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.web.js 1.7KB

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