Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

middleware.any.js 1.4KB

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