Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

reducer.ts 1.7KB

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