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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Sets up the persistence of the feature {@code virtual-background}.
  7. */
  8. PersistenceRegistry.register(STORE_NAME, true);
  9. /**
  10. * Reduces redux actions which activate/deactivate virtual background image, or
  11. * indicate if the virtual image background is activated/deactivated. The
  12. * backgroundEffectEnabled flag indicate if virtual background effect is activated.
  13. *
  14. * @param {State} state - The current redux state.
  15. * @param {Action} action - The redux action to reduce.
  16. * @param {string} action.type - The type of the redux action to reduce..
  17. * @returns {State} The next redux state that is the result of reducing the
  18. * specified action.
  19. */
  20. ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
  21. const { virtualSource, isVirtualBackground, backgroundEffectEnabled } = action;
  22. switch (action.type) {
  23. case SET_VIRTUAL_BACKGROUND: {
  24. return {
  25. ...state,
  26. virtualSource,
  27. isVirtualBackground
  28. };
  29. }
  30. case BACKGROUND_ENABLED: {
  31. return {
  32. ...state,
  33. backgroundEffectEnabled
  34. };
  35. }
  36. }
  37. return state;
  38. });