mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
482ad7d7c4
Might be overkill, but I'm trying to follow the same logic as for blocked users
24 lines
841 B
JavaScript
24 lines
841 B
JavaScript
import {
|
|
DOMAIN_BLOCKS_FETCH_SUCCESS,
|
|
DOMAIN_BLOCKS_EXPAND_SUCCESS,
|
|
DOMAIN_UNBLOCK_SUCCESS,
|
|
} from '../actions/domain_blocks';
|
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
|
|
|
const initialState = ImmutableMap({
|
|
blocks: ImmutableMap(),
|
|
});
|
|
|
|
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;
|
|
}
|
|
};
|