Insert state into strategic components rather than entire app

This commit is contained in:
John Furrow
2015-11-08 21:34:05 -08:00
parent cf11f386d8
commit 535652d074
12 changed files with 227 additions and 126 deletions
@@ -1,10 +1,42 @@
export default function torrentsReducer(state = [], action) {
import { selectTorrents } from '../util/selectTorrents';
const initialState = {
selectedTorrents: [],
torrents: []
};
export default function torrentsReducer(state = initialState, action) {
switch (action.type) {
case 'CLICK_TORRENT':
let event = action.payload.event;
let hash = action.payload.hash;
let selectedTorrents = Object.assign([], state.selectedTorrents);
let torrentList = action.payload.torrentList;
selectedTorrents = selectTorrents({
event,
hash,
selectedTorrents,
torrentList
});
return Object.assign(
{},
state,
{
...state,
selectedTorrents: selectedTorrents
}
);
case 'RECEIVE_TORRENTS':
return Object.assign(
[],
{},
state,
action.payload.torrents
{
...state,
torrents: action.payload.torrents
}
);
default: