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

12345678910111213141516171819202122232425262728293031323334
  1. // @flow
  2. import { ReducerRegistry, set } from '../base/redux';
  3. import {
  4. SET_FOLLOW_ME_MODERATOR,
  5. SET_FOLLOW_ME_STATE
  6. } from './actionTypes';
  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. });