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 2.9KB

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