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.ts 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import {
  3. SET_EVERYONE_ENABLED_E2EE,
  4. SET_EVERYONE_SUPPORT_E2EE,
  5. SET_MAX_MODE,
  6. TOGGLE_E2EE
  7. } from './actionTypes';
  8. import { MAX_MODE } from './constants';
  9. const DEFAULT_STATE = {
  10. enabled: false,
  11. maxMode: MAX_MODE.DISABLED
  12. };
  13. export interface IE2EEState {
  14. enabled: boolean;
  15. everyoneEnabledE2EE?: boolean;
  16. everyoneSupportE2EE?: boolean;
  17. maxMode: string;
  18. }
  19. /**
  20. * Reduces the Redux actions of the feature features/e2ee.
  21. */
  22. ReducerRegistry.register<IE2EEState>('features/e2ee', (state = DEFAULT_STATE, action): IE2EEState => {
  23. switch (action.type) {
  24. case TOGGLE_E2EE:
  25. return {
  26. ...state,
  27. enabled: action.enabled
  28. };
  29. case SET_EVERYONE_ENABLED_E2EE:
  30. return {
  31. ...state,
  32. everyoneEnabledE2EE: action.everyoneEnabledE2EE
  33. };
  34. case SET_EVERYONE_SUPPORT_E2EE:
  35. return {
  36. ...state,
  37. everyoneSupportE2EE: action.everyoneSupportE2EE
  38. };
  39. case SET_MAX_MODE: {
  40. return {
  41. ...state,
  42. maxMode: action.maxMode
  43. };
  44. }
  45. default:
  46. return state;
  47. }
  48. });