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.

23 lines
841 B

  1. import {
  2. DOMAIN_BLOCKS_FETCH_SUCCESS,
  3. DOMAIN_BLOCKS_EXPAND_SUCCESS,
  4. DOMAIN_UNBLOCK_SUCCESS,
  5. } from '../actions/domain_blocks';
  6. import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
  7. const initialState = ImmutableMap({
  8. blocks: ImmutableMap(),
  9. });
  10. export default function domainLists(state = initialState, action) {
  11. switch(action.type) {
  12. case DOMAIN_BLOCKS_FETCH_SUCCESS:
  13. return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
  14. case DOMAIN_BLOCKS_EXPAND_SUCCESS:
  15. return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next);
  16. case DOMAIN_UNBLOCK_SUCCESS:
  17. return state.updateIn(['blocks', 'items'], set => set.delete(action.domain));
  18. default:
  19. return state;
  20. }
  21. };