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

middleware.web.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
  3. import { CONFERENCE_JOINED, CONFERENCE_WILL_LEAVE } from '../base/conference';
  4. import {
  5. DOMINANT_SPEAKER_CHANGED,
  6. PARTICIPANT_JOINED,
  7. PARTICIPANT_LEFT,
  8. PARTICIPANT_UPDATED,
  9. PIN_PARTICIPANT,
  10. getParticipantById
  11. } from '../base/participants';
  12. import { MiddlewareRegistry } from '../base/redux';
  13. import { TRACK_ADDED } from '../base/tracks';
  14. import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
  15. import './middleware.any';
  16. declare var APP: Object;
  17. /**
  18. * Middleware which intercepts actions and updates the legacy component
  19. * {@code VideoLayout} as needed. The purpose of this middleware is to redux-ify
  20. * {@code VideoLayout} without having to simultaneously react-ifying it.
  21. *
  22. * @param {Store} store - The redux store.
  23. * @returns {Function}
  24. */
  25. // eslint-disable-next-line no-unused-vars
  26. MiddlewareRegistry.register(store => next => action => {
  27. // Purposefully perform additional actions after state update to mimic
  28. // being connected to the store for updates.
  29. const result = next(action);
  30. switch (action.type) {
  31. case CONFERENCE_JOINED:
  32. VideoLayout.mucJoined();
  33. break;
  34. case CONFERENCE_WILL_LEAVE:
  35. VideoLayout.reset();
  36. break;
  37. case PARTICIPANT_JOINED:
  38. if (!action.participant.local) {
  39. VideoLayout.addRemoteParticipantContainer(
  40. getParticipantById(store.getState(), action.participant.id));
  41. }
  42. break;
  43. case PARTICIPANT_LEFT:
  44. VideoLayout.removeParticipantContainer(action.participant.id);
  45. break;
  46. case PARTICIPANT_UPDATED: {
  47. // Look for actions that triggered a change to connectionStatus. This is
  48. // done instead of changing the connection status change action to be
  49. // explicit in order to minimize changes to other code.
  50. if (typeof action.participant.connectionStatus !== 'undefined') {
  51. VideoLayout.onParticipantConnectionStatusChanged(
  52. action.participant.id,
  53. action.participant.connectionStatus);
  54. }
  55. break;
  56. }
  57. case DOMINANT_SPEAKER_CHANGED:
  58. VideoLayout.onDominantSpeakerChanged(action.participant.id);
  59. break;
  60. case PIN_PARTICIPANT:
  61. VideoLayout.onPinChange(action.participant.id);
  62. break;
  63. case SET_FILMSTRIP_VISIBLE:
  64. VideoLayout.resizeVideoArea(true, false);
  65. APP.API.notifyFilmstripDisplayChanged(action.visible);
  66. break;
  67. case TRACK_ADDED:
  68. if (!action.track.local) {
  69. VideoLayout.onRemoteStreamAdded(action.track.jitsiTrack);
  70. }
  71. break;
  72. }
  73. return result;
  74. });