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.any.js 984B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {
  2. PIN_PARTICIPANT,
  3. getPinnedParticipant,
  4. pinParticipant
  5. } from '../base/participants';
  6. import { MiddlewareRegistry } from '../base/redux';
  7. import { SET_TILE_VIEW } from './actionTypes';
  8. import { setTileView } from './actions';
  9. /**
  10. * Middleware which intercepts actions and updates tile view related state.
  11. *
  12. * @param {Store} store - The redux store.
  13. * @returns {Function}
  14. */
  15. MiddlewareRegistry.register(store => next => action => {
  16. switch (action.type) {
  17. case PIN_PARTICIPANT: {
  18. const isPinning = Boolean(action.participant.id);
  19. const { tileViewEnabled } = store.getState()['features/video-layout'];
  20. if (isPinning && tileViewEnabled) {
  21. store.dispatch(setTileView(false));
  22. }
  23. break;
  24. }
  25. case SET_TILE_VIEW:
  26. if (getPinnedParticipant(store.getState()) && action.enabled) {
  27. store.dispatch(pinParticipant(null));
  28. }
  29. break;
  30. }
  31. return next(action);
  32. });