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

middleware.web.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
  3. import UIEvents from '../../../service/UI/UIEvents';
  4. import { CONFERENCE_JOINED } from '../base/conference';
  5. import {
  6. DOMINANT_SPEAKER_CHANGED,
  7. PARTICIPANT_JOINED,
  8. PARTICIPANT_LEFT,
  9. PARTICIPANT_UPDATED,
  10. PIN_PARTICIPANT,
  11. getParticipantById
  12. } from '../base/participants';
  13. import { MiddlewareRegistry } from '../base/redux';
  14. import { TRACK_ADDED } from '../base/tracks';
  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_JOINED:
  31. VideoLayout.mucJoined();
  32. break;
  33. case PARTICIPANT_JOINED:
  34. if (!action.participant.local) {
  35. VideoLayout.addRemoteParticipantContainer(
  36. getParticipantById(store.getState(), action.participant.id));
  37. }
  38. break;
  39. case PARTICIPANT_LEFT:
  40. VideoLayout.removeParticipantContainer(action.participant.id);
  41. break;
  42. case PARTICIPANT_UPDATED: {
  43. // Look for actions that triggered a change to connectionStatus. This is
  44. // done instead of changing the connection status change action to be
  45. // explicit in order to minimize changes to other code.
  46. if (typeof action.participant.connectionStatus !== 'undefined') {
  47. VideoLayout.onParticipantConnectionStatusChanged(
  48. action.participant.id);
  49. }
  50. break;
  51. }
  52. case DOMINANT_SPEAKER_CHANGED:
  53. VideoLayout.onDominantSpeakerChanged(action.participant.id);
  54. break;
  55. case PIN_PARTICIPANT:
  56. VideoLayout.onPinChange(action.participant.id);
  57. APP.UI.emitEvent(
  58. UIEvents.PINNED_ENDPOINT,
  59. action.participant.id,
  60. Boolean(action.participant.id));
  61. break;
  62. case TRACK_ADDED:
  63. if (!action.track.local) {
  64. VideoLayout.onRemoteStreamAdded(action.track.jitsiTrack);
  65. }
  66. break;
  67. }
  68. return result;
  69. });