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 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 './middleware.any';
  14. declare var APP: Object;
  15. /**
  16. * Middleware which intercepts actions and updates the legacy component
  17. * {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
  18. * {@code VideoLayout} without having to simultaneously react-ifying it.
  19. *
  20. * @param {Store} store - The redux store.
  21. * @returns {Function}
  22. */
  23. // eslint-disable-next-line no-unused-vars
  24. MiddlewareRegistry.register(store => next => action => {
  25. // Purposefully perform additional actions after state update to mimic
  26. // being connected to the store for updates.
  27. const result = next(action);
  28. switch (action.type) {
  29. case CONFERENCE_WILL_LEAVE:
  30. VideoLayout.reset();
  31. break;
  32. case PARTICIPANT_JOINED:
  33. if (!action.participant.local) {
  34. VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
  35. }
  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. action.participant.connectionStatus);
  45. }
  46. break;
  47. }
  48. case SET_FILMSTRIP_VISIBLE:
  49. VideoLayout.resizeVideoArea();
  50. break;
  51. case TRACK_ADDED:
  52. if (action.track.mediaType !== MEDIA_TYPE.AUDIO) {
  53. VideoLayout._updateLargeVideoIfDisplayed(action.track.participantId, true);
  54. }
  55. break;
  56. case TRACK_STOPPED: {
  57. if (action.track.jitsiTrack.isLocal()) {
  58. const participant = getLocalParticipant(store.getState);
  59. VideoLayout._updateLargeVideoIfDisplayed(participant?.id);
  60. }
  61. break;
  62. }
  63. case TRACK_REMOVED:
  64. if (!action.track.local && action.track.mediaType !== MEDIA_TYPE.AUDIO) {
  65. VideoLayout.updateVideoMutedForNoTracks(action.track.jitsiTrack.getParticipantId());
  66. }
  67. break;
  68. }
  69. return result;
  70. });