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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';
  13. import './middleware.any';
  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 CONFERENCE_WILL_LEAVE:
  29. VideoLayout.reset();
  30. break;
  31. case PARTICIPANT_JOINED:
  32. if (!action.participant.local) {
  33. VideoLayout.updateVideoMutedForNoTracks(action.participant.id);
  34. }
  35. break;
  36. case PARTICIPANT_UPDATED: {
  37. // Look for actions that triggered a change to connectionStatus. This is
  38. // done instead of changing the connection status change action to be
  39. // explicit in order to minimize changes to other code.
  40. if (typeof action.participant.connectionStatus !== 'undefined') {
  41. VideoLayout.onParticipantConnectionStatusChanged(
  42. action.participant.id,
  43. action.participant.connectionStatus);
  44. }
  45. break;
  46. }
  47. case PARTICIPANTS_PANE_CLOSE:
  48. case PARTICIPANTS_PANE_OPEN:
  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. });