2017-08-20 17:57:57 +02:00
|
|
|
import { UPDATE_RESOURCES } from '../actions/resources';
|
|
|
|
|
|
|
|
export default function torrents(state = {}, action) {
|
|
|
|
switch (action.type) {
|
2017-08-22 00:10:52 +02:00
|
|
|
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-22 00:10:52 +02:00
|
|
|
};
|
2017-08-20 17:57:57 +02:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|