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.

reducer.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // @flow
  2. import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
  3. import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';
  4. const STORE_NAME = 'features/virtual-background';
  5. /**
  6. * Reduces redux actions which activate/deactivate virtual background image, or
  7. * indicate if the virtual image background is activated/deactivated. The
  8. * backgroundEffectEnabled flag indicate if virtual background effect is activated.
  9. *
  10. * @param {State} state - The current redux state.
  11. * @param {Action} action - The redux action to reduce.
  12. * @param {string} action.type - The type of the redux action to reduce..
  13. * @returns {State} The next redux state that is the result of reducing the
  14. * specified action.
  15. */
  16. ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
  17. const { virtualSource, backgroundEffectEnabled, blurValue, backgroundType, selectedThumbnail } = action;
  18. /**
  19. * Sets up the persistence of the feature {@code virtual-background}.
  20. */
  21. PersistenceRegistry.register(STORE_NAME, state.backgroundType !== 'desktop-share');
  22. switch (action.type) {
  23. case SET_VIRTUAL_BACKGROUND: {
  24. return {
  25. ...state,
  26. virtualSource,
  27. blurValue,
  28. backgroundType,
  29. selectedThumbnail
  30. };
  31. }
  32. case BACKGROUND_ENABLED: {
  33. return {
  34. ...state,
  35. backgroundEffectEnabled
  36. };
  37. }
  38. }
  39. return state;
  40. });