logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

domain_lists.js (841B)


  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. };