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 1014B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import ReducerRegistry from '../base/redux/ReducerRegistry';
  2. import { set } from '../base/redux/functions';
  3. import {
  4. SET_FOLLOW_ME_MODERATOR,
  5. SET_FOLLOW_ME_STATE
  6. } from './actionTypes';
  7. export interface IFollowMeState {
  8. moderator?: string;
  9. state?: {
  10. [key: string]: string;
  11. };
  12. }
  13. /**
  14. * Listen for actions that contain the Follow Me feature active state, so that it can be stored.
  15. */
  16. ReducerRegistry.register<IFollowMeState>(
  17. 'features/follow-me',
  18. (state = {}, action): IFollowMeState => {
  19. switch (action.type) {
  20. case SET_FOLLOW_ME_MODERATOR: {
  21. let newState = set(state, 'moderator', action.id);
  22. if (!action.id) {
  23. // clear the state if feature becomes disabled
  24. newState = set(newState, 'state', undefined);
  25. }
  26. return newState;
  27. }
  28. case SET_FOLLOW_ME_STATE: {
  29. return set(state, 'state', action.state);
  30. }
  31. }
  32. return state;
  33. });