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

12345678910111213141516171819202122232425262728293031323334353637
  1. // @flow
  2. import { JitsiTrackEvents } from '../base/lib-jitsi-meet';
  3. import { MiddlewareRegistry } from '../base/redux';
  4. import { getLocalVideoTrack } from '../base/tracks';
  5. import { toggleBackgroundEffect } from './actions';
  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 === 'desktop') {
  19. const noneOptions = {
  20. enabled: false,
  21. backgroundType: 'none',
  22. selectedThumbnail: 'none',
  23. backgroundEffectEnabled: false
  24. };
  25. virtualSource
  26. && virtualSource.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, () => {
  27. dispatch(toggleBackgroundEffect(noneOptions, currentLocalTrack.jitsiTrack));
  28. });
  29. }
  30. return next(action);
  31. });