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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // @flow
  2. import VideoLayout from '../../../modules/UI/videolayout/VideoLayout';
  3. import { PARTICIPANT_JOINED, PARTICIPANT_LEFT } from '../base/participants';
  4. import { MiddlewareRegistry } from '../base/redux';
  5. import { CLIENT_RESIZED } from '../base/responsive-ui';
  6. import { SETTINGS_UPDATED } from '../base/settings';
  7. import {
  8. getCurrentLayout,
  9. LAYOUTS
  10. } from '../video-layout';
  11. import {
  12. setHorizontalViewDimensions,
  13. setTileViewDimensions,
  14. setVerticalViewDimensions
  15. } from './actions';
  16. import { updateRemoteParticipants, updateRemoteParticipantsOnLeave } from './functions';
  17. import './subscriber';
  18. /**
  19. * The middleware of the feature Filmstrip.
  20. */
  21. MiddlewareRegistry.register(store => next => action => {
  22. if (action.type === PARTICIPANT_LEFT) {
  23. // This has to be executed before we remove the participant from features/base/participants state in order to
  24. // remove the related thumbnail component before we need to re-render it. If we do this after next()
  25. // we will be in sitation where the participant exists in the remoteParticipants array in features/filmstrip
  26. // but doesn't exist in features/base/participants state which will lead to rendering a thumbnail for
  27. // non-existing participant.
  28. updateRemoteParticipantsOnLeave(store, action.participant?.id);
  29. }
  30. const result = next(action);
  31. switch (action.type) {
  32. case CLIENT_RESIZED: {
  33. const state = store.getState();
  34. const layout = getCurrentLayout(state);
  35. switch (layout) {
  36. case LAYOUTS.TILE_VIEW: {
  37. const { gridDimensions } = state['features/filmstrip'].tileViewDimensions;
  38. store.dispatch(setTileViewDimensions(gridDimensions));
  39. break;
  40. }
  41. case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
  42. store.dispatch(setHorizontalViewDimensions());
  43. break;
  44. case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
  45. store.dispatch(setVerticalViewDimensions());
  46. break;
  47. }
  48. break;
  49. }
  50. case PARTICIPANT_JOINED: {
  51. updateRemoteParticipants(store, action.participant?.id);
  52. break;
  53. }
  54. case SETTINGS_UPDATED: {
  55. if (typeof action.settings?.localFlipX === 'boolean') {
  56. // TODO: This needs to be removed once the large video is Reactified.
  57. VideoLayout.onLocalFlipXChanged();
  58. }
  59. break;
  60. }
  61. }
  62. return result;
  63. });