import { BlockedRequester , RequesterBlockMap , RequesterId } from '../types' ; import { BlockRequesterAction } from '../actions/blockRequester' ; import { REQUESTER_BLOCKLIST_ADD , REQUESTER_BLOCKLIST_REMOVE , } from '../constants' ; import { Map } from 'immutable' ; const initial = Map < RequesterId , BlockedRequester > ( ) ; export default ( state = initial , action ) : RequesterBlockMap => { switch ( action . type ) { case REQUESTER_BLOCKLIST_ADD : return action . data . reduce ( ( acc , cur ) => acc . set ( cur . id , cur ) , state ) ; case REQUESTER_BLOCKLIST_REMOVE : return state . filterNot ( ( blockedRequester ) => action . requesterIds . has ( blockedRequester . id ) ) as RequesterBlockMap ; default : return state ; } } ;