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

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