You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

middleware.web.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout.js';
  3. import UIEvents from '../../../service/UI/UIEvents';
  4. import { CONFERENCE_JOINED, CONFERENCE_WILL_LEAVE } 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 CONFERENCE_WILL_LEAVE:
  37. VideoLayout.reset();
  38. break;
  39. case PARTICIPANT_JOINED:
  40. if (!action.participant.local) {
  41. VideoLayout.addRemoteParticipantContainer(
  42. getParticipantById(store.getState(), action.participant.id));
  43. }
  44. break;
  45. case PARTICIPANT_LEFT:
  46. VideoLayout.removeParticipantContainer(action.participant.id);
  47. break;
  48. case PARTICIPANT_UPDATED: {
  49. // Look for actions that triggered a change to connectionStatus. This is
  50. // done instead of changing the connection status change action to be
  51. // explicit in order to minimize changes to other code.
  52. if (typeof action.participant.connectionStatus !== 'undefined') {
  53. VideoLayout.onParticipantConnectionStatusChanged(
  54. action.participant.id,
  55. action.participant.connectionStatus);
  56. }
  57. break;
  58. }
  59. case DOMINANT_SPEAKER_CHANGED:
  60. VideoLayout.onDominantSpeakerChanged(action.participant.id);
  61. break;
  62. case PIN_PARTICIPANT:
  63. VideoLayout.onPinChange(action.participant.id);
  64. APP.UI.emitEvent(
  65. UIEvents.PINNED_ENDPOINT,
  66. action.participant.id,
  67. Boolean(action.participant.id));
  68. break;
  69. case SET_FILMSTRIP_VISIBLE:
  70. VideoLayout.resizeVideoArea(true, false);
  71. APP.UI.emitEvent(UIEvents.TOGGLED_FILMSTRIP, action.visible);
  72. break;
  73. case SET_TILE_VIEW:
  74. APP.UI.emitEvent(UIEvents.TOGGLED_TILE_VIEW, action.enabled);
  75. break;
  76. case TRACK_ADDED:
  77. if (!action.track.local) {
  78. VideoLayout.onRemoteStreamAdded(action.track.jitsiTrack);
  79. }
  80. break;
  81. }
  82. return result;
  83. });