diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-28 22:48:38 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-28 22:48:38 +0200 |
| commit | bcf119f2c4ac587cc8263db8a9fc0581521fdec7 (patch) | |
| tree | c7c78a13d575b8345d729bb5aa44022d7f0715d4 /src/reducers/states.js | |
| parent | f29305d4c966af83a0a842f78dcb7adb7128b37c (diff) | |
Implement batch state adding
Also fixes the 'hidden states' bug.
Diffstat (limited to 'src/reducers/states.js')
| -rw-r--r-- | src/reducers/states.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/reducers/states.js b/src/reducers/states.js index d74c924c..81f078af 100644 --- a/src/reducers/states.js +++ b/src/reducers/states.js @@ -1,5 +1,5 @@ import {combineReducers} from "redux"; -import {ADD_TO_STATES} from "../actions/states"; +import {ADD_BATCH_TO_STATES} from "../actions/states"; export const states = combineReducers({ task: objectStates("task"), @@ -14,17 +14,21 @@ function objectStates(type) { return state; } - if (action.type === ADD_TO_STATES) { + if (action.type === ADD_BATCH_TO_STATES) { + const batch = {}; + for (let i in action.objects) { + batch[action.objects[i].tick] = Object.assign( + {}, + state[action.objects[i].tick], + batch[action.objects[i].tick], + {[action.objects[i][action.objectType + "Id"]]: action.objects[i]} + ); + } + return Object.assign( {}, state, - { - [action.tick]: Object.assign( - {}, - state[action.tick], - {[action.object[action.objectType + "Id"]]: action.object} - ) - } + batch ); } |
