Update the torrent reducer from switch to map
This commit is contained in:
parent
7014b3933d
commit
99fbe22d6d
@ -1,20 +1,17 @@
|
||||
import { Map, List, fromJS } from 'immutable'
|
||||
import { Map, List, fromJS } from "immutable"
|
||||
|
||||
const defaultState = Map({
|
||||
'fetching': false,
|
||||
'torrents': List(),
|
||||
"fetching": false,
|
||||
"torrents": List(),
|
||||
});
|
||||
|
||||
export default function torrentStore(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
case 'TORRENTS_FETCH_PENDING':
|
||||
return state.set('fetching', false);
|
||||
case 'TORRENTS_FETCH_FULFILLED':
|
||||
return state.merge(fromJS({
|
||||
fetching: false,
|
||||
torrents: action.payload.response.data,
|
||||
}));
|
||||
default:
|
||||
return state
|
||||
}
|
||||
const handlers = {
|
||||
"TORRENTS_FETCH_PENDING": state => state.set("fetching", false),
|
||||
"TORRENTS_FETCH_FULFILLED": (state, action) => state.merge(fromJS({
|
||||
fetching: false,
|
||||
torrents: action.payload.response.data,
|
||||
})),
|
||||
}
|
||||
|
||||
export default (state = defaultState, action) =>
|
||||
handlers[action.type] ? handlers[action.type](state, action) : state;
|
||||
|
Loading…
x
Reference in New Issue
Block a user