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

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