您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

middleware.web.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. action.participant.connectionStatus);
  50. }
  51. break;
  52. }
  53. case DOMINANT_SPEAKER_CHANGED:
  54. VideoLayout.onDominantSpeakerChanged(action.participant.id);
  55. break;
  56. case PIN_PARTICIPANT:
  57. VideoLayout.onPinChange(action.participant.id);
  58. APP.UI.emitEvent(
  59. UIEvents.PINNED_ENDPOINT,
  60. action.participant.id,
  61. Boolean(action.participant.id));
  62. break;
  63. case TRACK_ADDED:
  64. if (!action.track.local) {
  65. VideoLayout.onRemoteStreamAdded(action.track.jitsiTrack);
  66. }
  67. break;
  68. }
  69. return result;
  70. });