Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

middleware.ts 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {
  2. DOMINANT_SPEAKER_CHANGED,
  3. PARTICIPANT_JOINED,
  4. PARTICIPANT_LEFT,
  5. PIN_PARTICIPANT
  6. } from '../base/participants/actionTypes';
  7. import { getDominantSpeakerParticipant, getLocalParticipant } from '../base/participants/functions';
  8. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  9. import { isTestModeEnabled } from '../base/testing/functions';
  10. import {
  11. TRACK_ADDED,
  12. TRACK_REMOVED
  13. } from '../base/tracks/actionTypes';
  14. import { TOGGLE_DOCUMENT_EDITING } from '../etherpad/actionTypes';
  15. import { selectParticipantInLargeVideo } from './actions';
  16. import logger from './logger';
  17. import './subscriber';
  18. /**
  19. * Middleware that catches actions related to participants and tracks and
  20. * dispatches an action to select a participant depicted by LargeVideo.
  21. *
  22. * @param {Store} store - Redux store.
  23. * @returns {Function}
  24. */
  25. MiddlewareRegistry.register(store => next => action => {
  26. switch (action.type) {
  27. case DOMINANT_SPEAKER_CHANGED: {
  28. const state = store.getState();
  29. const localParticipant = getLocalParticipant(state);
  30. const dominantSpeaker = getDominantSpeakerParticipant(state);
  31. if (dominantSpeaker?.id === action.participant.id) {
  32. return next(action);
  33. }
  34. const result = next(action);
  35. if (isTestModeEnabled(state)) {
  36. logger.info(`Dominant speaker changed event for: ${action.participant.id}`);
  37. }
  38. if (localParticipant && localParticipant.id !== action.participant.id) {
  39. store.dispatch(selectParticipantInLargeVideo());
  40. }
  41. return result;
  42. }
  43. case PIN_PARTICIPANT: {
  44. const result = next(action);
  45. store.dispatch(selectParticipantInLargeVideo(action.participant?.id));
  46. return result;
  47. }
  48. case PARTICIPANT_JOINED:
  49. case PARTICIPANT_LEFT:
  50. case TOGGLE_DOCUMENT_EDITING:
  51. case TRACK_ADDED:
  52. case TRACK_REMOVED: {
  53. const result = next(action);
  54. store.dispatch(selectParticipantInLargeVideo());
  55. return result;
  56. }
  57. }
  58. const result = next(action);
  59. return result;
  60. });