Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

middleware.web.js 2.9KB

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