2023-05-24 00:15:17 +09:00
|
|
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
|
|
|
2018-03-30 19:38:00 +09:00
|
|
|
import {
|
|
|
|
DOMAIN_BLOCKS_FETCH_SUCCESS,
|
|
|
|
DOMAIN_BLOCKS_EXPAND_SUCCESS,
|
2023-11-04 00:00:03 +09:00
|
|
|
unblockDomainSuccess
|
2018-03-30 19:38:00 +09:00
|
|
|
} from '../actions/domain_blocks';
|
|
|
|
|
|
|
|
const initialState = ImmutableMap({
|
2018-05-29 23:25:05 +09:00
|
|
|
blocks: ImmutableMap({
|
|
|
|
items: ImmutableOrderedSet(),
|
|
|
|
}),
|
2018-03-30 19:38:00 +09: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);
|
2023-11-04 00:00:03 +09:00
|
|
|
case unblockDomainSuccess.type:
|
|
|
|
return state.updateIn(['blocks', 'items'], set => set.delete(action.payload.domain));
|
2018-03-30 19:38:00 +09:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2022-12-19 00:51:37 +09:00
|
|
|
}
|