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.

25 lines
880 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. items: ImmutableOrderedSet(),
  10. }),
  11. });
  12. export default function domainLists(state = initialState, action) {
  13. switch(action.type) {
  14. case DOMAIN_BLOCKS_FETCH_SUCCESS:
  15. return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
  16. case DOMAIN_BLOCKS_EXPAND_SUCCESS:
  17. return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next);
  18. case DOMAIN_UNBLOCK_SUCCESS:
  19. return state.updateIn(['blocks', 'items'], set => set.delete(action.domain));
  20. default:
  21. return state;
  22. }
  23. };