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

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. recorder?: boolean;
  10. state?: {
  11. [key: string]: string;
  12. };
  13. }
  14. /**
  15. * Listen for actions that contain the Follow Me feature active state, so that it can be stored.
  16. */
  17. ReducerRegistry.register<IFollowMeState>(
  18. 'features/follow-me',
  19. (state = {}, action): IFollowMeState => {
  20. switch (action.type) {
  21. case SET_FOLLOW_ME_MODERATOR: {
  22. let newState = set(state, 'moderator', action.id);
  23. if (action.id) {
  24. newState = set(newState, 'recorder', action.forRecorder);
  25. } else {
  26. // clear the state if feature becomes disabled
  27. newState = set(newState, 'state', undefined);
  28. newState = set(newState, 'recorder', undefined);
  29. }
  30. return newState;
  31. }
  32. case SET_FOLLOW_ME_STATE: {
  33. return set(state, 'state', action.state);
  34. }
  35. }
  36. return state;
  37. });