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 1010B

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