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.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // @flow
  2. import { setLastN } from '../base/conference';
  3. import { SET_CALLEE_INFO_VISIBLE } from '../base/jwt';
  4. import { pinParticipant } from '../base/participants';
  5. import { MiddlewareRegistry } from '../base/redux';
  6. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  7. import { SET_FILMSTRIP_ENABLED } from './actionTypes';
  8. declare var APP: Object;
  9. MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
  10. switch (action.type) {
  11. case SET_CALLEE_INFO_VISIBLE:
  12. if (typeof APP !== 'undefined') {
  13. const oldValue
  14. = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
  15. const result = next(action);
  16. const newValue
  17. = Boolean(getState()['features/base/jwt'].calleeInfoVisible);
  18. oldValue === newValue
  19. // FIXME The following accesses the private state filmstrip of
  20. // Filmstrip. It is written with the understanding that
  21. // Filmstrip will be rewritten in React and, consequently, will
  22. // not need the middleware implemented here, Filmstrip.init, and
  23. // UI.start.
  24. || (Filmstrip.filmstrip
  25. && Filmstrip.toggleFilmstrip(!newValue));
  26. return result;
  27. }
  28. break;
  29. case SET_FILMSTRIP_ENABLED:
  30. // FIXME: Only do this on mobile for now. The logic for participant
  31. // pinning / unpinning is not on React yet so dispatching the action
  32. // is not enough.
  33. if (typeof APP === 'undefined') {
  34. const { audioOnly } = getState()['features/base/conference'];
  35. const { enabled } = action;
  36. !enabled && dispatch(pinParticipant(null));
  37. !audioOnly && dispatch(setLastN(enabled ? undefined : 1));
  38. }
  39. break;
  40. }
  41. return next(action);
  42. });