receptor/src/reducers/torrents.js

18 lines
410 B
JavaScript
Raw Normal View History

2017-08-20 17:57:57 +02:00
import { UPDATE_RESOURCES } from '../actions/resources';
export default function torrents(state = {}, action) {
switch (action.type) {
case UPDATE_RESOURCES:
return {
...state,
...action.resources
.filter(r => r.type === "torrent")
2017-08-23 14:27:08 +02:00
.reduce((s, r) => ({
...s,
[r.id]: { ...s[r.id], ...r }
}), {})
};
2017-08-20 17:57:57 +02:00
}
return state;
}