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

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