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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* @flow */
  2. import { MiddlewareRegistry } from '../base/redux';
  3. import { SET_CALL_OVERLAY_VISIBLE } from '../jwt';
  4. import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
  5. import UIEvents from '../../../service/UI/UIEvents';
  6. import {
  7. SET_FILMSTRIP_REMOTE_VIDEOS_VISIBLITY,
  8. SET_FILMSTRIP_VISIBILITY
  9. } from './actionTypes';
  10. declare var APP: Object;
  11. // eslint-disable-next-line no-unused-vars
  12. MiddlewareRegistry.register(({ getState }) => next => action => {
  13. switch (action.type) {
  14. case SET_CALL_OVERLAY_VISIBLE:
  15. if (typeof APP !== 'undefined') {
  16. const oldValue
  17. = Boolean(getState()['features/jwt'].callOverlayVisible);
  18. const result = next(action);
  19. const newValue
  20. = Boolean(getState()['features/jwt'].callOverlayVisible);
  21. oldValue === newValue
  22. // FIXME The following accesses the private state filmstrip of
  23. // Filmstrip. It is written with the understanding that
  24. // Filmstrip will be rewritten in React and, consequently, will
  25. // not need the middleware implemented here, Filmstrip.init, and
  26. // UI.start.
  27. || (Filmstrip.filmstrip
  28. && Filmstrip.toggleFilmstrip(!newValue, false));
  29. return result;
  30. }
  31. break;
  32. case SET_FILMSTRIP_REMOTE_VIDEOS_VISIBLITY:
  33. case SET_FILMSTRIP_VISIBILITY: {
  34. const result = next(action);
  35. typeof APP === 'undefined'
  36. || APP.UI.emitEvent(UIEvents.UPDATED_FILMSTRIP_DISPLAY);
  37. return result;
  38. }
  39. }
  40. return next(action);
  41. });