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

middleware.web.js 2.1KB

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