2023-05-23 11:15:17 -04:00
|
|
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
|
|
|
2018-03-30 06:38:00 -04:00
|
|
|
import {
|
|
|
|
DOMAIN_BLOCKS_FETCH_SUCCESS,
|
|
|
|
DOMAIN_BLOCKS_EXPAND_SUCCESS,
|
|
|
|
DOMAIN_UNBLOCK_SUCCESS,
|
|
|
|
} from '../actions/domain_blocks';
|
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
2018-05-29 10:25:05 -04:00
|
|
|
blocks: ImmutableMap({
|
|
|
|
items: ImmutableOrderedSet(),
|
|
|
|
}),
|
2018-03-30 06:38:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default function domainLists(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
case DOMAIN_BLOCKS_FETCH_SUCCESS:
|
|
|
|
return state.setIn(['blocks', 'items'], ImmutableOrderedSet(action.domains)).setIn(['blocks', 'next'], action.next);
|
|
|
|
case DOMAIN_BLOCKS_EXPAND_SUCCESS:
|
|
|
|
return state.updateIn(['blocks', 'items'], set => set.union(action.domains)).setIn(['blocks', 'next'], action.next);
|
|
|
|
case DOMAIN_UNBLOCK_SUCCESS:
|
|
|
|
return state.updateIn(['blocks', 'items'], set => set.delete(action.domain));
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2022-12-18 10:51:37 -05:00
|
|
|
}
|