2020-01-29 16:45:17 +00:00
|
|
|
import { POLLS_IMPORT } from '../actions/importer';
|
2019-07-02 08:10:25 +01:00
|
|
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
|
|
|
|
|
|
|
const importPolls = (state, polls) => state.withMutations(map => polls.forEach(poll => map.set(poll.id, fromJS(poll))));
|
|
|
|
|
|
|
|
const initialState = ImmutableMap();
|
|
|
|
|
|
|
|
export default function polls(state = initialState, action) {
|
|
|
|
switch(action.type) {
|
|
|
|
case POLLS_IMPORT:
|
|
|
|
return importPolls(state, action.polls);
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|