Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

middleware.ts 1.0KB

1234567891011121314151617181920212223242526
  1. import { VIDEO_TYPE } from '../base/media/constants';
  2. import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
  3. import { getLocalVideoTrack } from '../base/tracks/functions';
  4. import { SET_VIRTUAL_BACKGROUND } from './actionTypes';
  5. import { localTrackStopped } from './functions';
  6. /**
  7. * Middleware which intercepts the desktop video type on
  8. * virtual background. If the user stops the screen share
  9. * then the default virtual background is set to 'none' option.
  10. *
  11. * @param {Store} store - The redux store.
  12. * @returns {Function}
  13. */
  14. MiddlewareRegistry.register(store => next => action => {
  15. const { dispatch, getState } = store;
  16. const virtualSource = getState()['features/virtual-background'].virtualSource;
  17. const currentLocalTrack = getLocalVideoTrack(getState()['features/base/tracks']);
  18. if (virtualSource?.videoType === VIDEO_TYPE.DESKTOP && action.type === SET_VIRTUAL_BACKGROUND) {
  19. localTrackStopped(dispatch, virtualSource, currentLocalTrack?.jitsiTrack);
  20. }
  21. return next(action);
  22. });