Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

middleware.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // @flow
  2. import { setLastN } from '../base/conference';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { SET_FILMSTRIP_ENABLED } from './actionTypes';
  5. declare var APP: Object;
  6. MiddlewareRegistry.register(store => next => action => {
  7. switch (action.type) {
  8. case SET_FILMSTRIP_ENABLED:
  9. return _setFilmstripEnabled(store, next, action);
  10. }
  11. return next(action);
  12. });
  13. /**
  14. * Notifies the feature filmstrip that the action {@link SET_FILMSTRIP_ENABLED}
  15. * is being dispatched within a specific redux store.
  16. *
  17. * @param {Store} store - The redux store in which the specified action is being
  18. * dispatched.
  19. * @param {Dispatch} next - The redux dispatch function to dispatch the
  20. * specified action to the specified store.
  21. * @param {Action} action - The redux action {@code SET_FILMSTRIP_ENABLED} which
  22. * is being dispatched in the specified store.
  23. * @private
  24. * @returns {Object} The value returned by {@code next(action)}.
  25. */
  26. function _setFilmstripEnabled({ dispatch, getState }, next, action) {
  27. const result = next(action);
  28. // FIXME This action is not currently dispatched on web.
  29. if (typeof APP === 'undefined') {
  30. const state = getState();
  31. const { enabled } = state['features/filmstrip'];
  32. const { audioOnly } = state['features/base/conference'];
  33. // FIXME Audio-only mode fiddles with lastN as well. That's why we don't
  34. // touch lastN in audio-only mode. But it's not clear what the value of
  35. // lastN should be upon exit from audio-only mode if the filmstrip is
  36. // disabled already. Currently, audio-only mode will set undefined
  37. // regardless of whether the filmstrip is disabled. But we don't have a
  38. // practical use case in which audio-only mode is exited while the
  39. // filmstrip is disabled.
  40. audioOnly || dispatch(setLastN(enabled ? undefined : 1));
  41. }
  42. return result;
  43. }