Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

middleware.web.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
  3. import { CONFERENCE_WILL_LEAVE } from '../base/conference';
  4. import { MEDIA_TYPE } from '../base/media';
  5. import {
  6. getLocalParticipant,
  7. PARTICIPANT_JOINED,
  8. PARTICIPANT_UPDATED
  9. } from '../base/participants';
  10. import { MiddlewareRegistry } from '../base/redux';
  11. import { TRACK_ADDED, TRACK_REMOVED, TRACK_STOPPED } from '../base/tracks';
  12. import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
  13. import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes.js';
  14. import './middleware.any';
  15. declare var APP: Object;
  16. /**
  17. * Middleware which intercepts actions and updates the legacy component
  18. * {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
  19. * {@code VideoLayout} without having to simultaneously react-ifying it.
  20. *
  21. * @param {Store} store - The redux store.
  22. * @returns {Function}
  23. */
  24. // eslint-disable-next-line no-unused-vars
  25. MiddlewareRegistry.register(store => next => action => {
  26. // Purposefully perform additional actions after state update to mimic
  27. // being connected to the store for updates.
  28. const result = next(action);
  29. switch (action.type) {
  30. case CONFERENCE_WILL_LEAVE:
  31. VideoLayout.reset();
  32. break;
  33. case PARTICIPANT_JOINED:
  34. if (!action.participant.local) {
  35. VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
  36. }
  37. break;
  38. case PARTICIPANT_UPDATED: {
  39. // Look for actions that triggered a change to connectionStatus. This is
  40. // done instead of changing the connection status change action to be
  41. // explicit in order to minimize changes to other code.
  42. if (typeof action.participant.connectionStatus !== 'undefined') {
  43. VideoLayout.onParticipantConnectionStatusChanged(
  44. action.participant.id,
  45. action.participant.connectionStatus);
  46. }
  47. break;
  48. }
  49. case PARTICIPANTS_PANE_CLOSE:
  50. case PARTICIPANTS_PANE_OPEN:
  51. case SET_FILMSTRIP_VISIBLE:
  52. VideoLayout.resizeVideoArea();
  53. break;
  54. case TRACK_ADDED:
  55. if (action.track.mediaType !== MEDIA_TYPE.AUDIO) {
  56. VideoLayout._updateLargeVideoIfDisplayed(action.track.participantId, true);
  57. }
  58. break;
  59. case TRACK_STOPPED: {
  60. if (action.track.jitsiTrack.isLocal()) {
  61. const participant = getLocalParticipant(store.getState);
  62. VideoLayout._updateLargeVideoIfDisplayed(participant?.id);
  63. }
  64. break;
  65. }
  66. case TRACK_REMOVED:
  67. if (!action.track.local && action.track.mediaType !== MEDIA_TYPE.AUDIO) {
  68. VideoLayout.updateVideoMutedForNoTracks(action.track.jitsiTrack.getParticipantId());
  69. }
  70. break;
  71. }
  72. return result;
  73. });