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

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