Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

middleware.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {
  2. DOMINANT_SPEAKER_CHANGED,
  3. PARTICIPANT_JOINED,
  4. PARTICIPANT_LEFT,
  5. PIN_PARTICIPANT
  6. } from '../base/participants';
  7. import { MiddlewareRegistry } from '../base/redux';
  8. import {
  9. getTrackByJitsiTrack,
  10. TRACK_ADDED,
  11. TRACK_REMOVED,
  12. TRACK_UPDATED
  13. } from '../base/tracks';
  14. import {
  15. selectParticipant,
  16. selectParticipantInLargeVideo
  17. } from './actions';
  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. const result = next(action);
  27. switch (action.type) {
  28. case DOMINANT_SPEAKER_CHANGED:
  29. case PARTICIPANT_JOINED:
  30. case PARTICIPANT_LEFT:
  31. case PIN_PARTICIPANT:
  32. case TRACK_ADDED:
  33. case TRACK_REMOVED:
  34. store.dispatch(selectParticipantInLargeVideo());
  35. break;
  36. case TRACK_UPDATED: {
  37. // In order to minimize re-calculations, we need to select participant
  38. // only if the videoType of the current participant rendered in
  39. // LargeVideo has changed.
  40. if ('videoType' in action.track) {
  41. const state = store.getState();
  42. const track
  43. = getTrackByJitsiTrack(
  44. state['features/base/tracks'],
  45. action.track.jitsiTrack);
  46. const participantId = state['features/largeVideo'].participantId;
  47. if (track.participantId === participantId) {
  48. store.dispatch(selectParticipant());
  49. }
  50. }
  51. break;
  52. }
  53. }
  54. return result;
  55. });