summaryrefslogtreecommitdiff
path: root/frontend/src/redux/errors.js
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@gmail.com>2017-05-28 21:32:36 +0200
committerGitHub <noreply@github.com>2017-05-28 21:32:36 +0200
commitba9cd259ed1ca2370565265eab9fe2628ad6502c (patch)
tree0c24821770274a414f80b3092d5be54902c042d9 /frontend/src/redux/errors.js
parentFix proxy not working since CRA upgrade (diff)
parentMove to immutable with Records (diff)
downloadseven-wonders-ba9cd259ed1ca2370565265eab9fe2628ad6502c.tar.gz
seven-wonders-ba9cd259ed1ca2370565265eab9fe2628ad6502c.tar.bz2
seven-wonders-ba9cd259ed1ca2370565265eab9fe2628ad6502c.zip
Merge pull request #14 from luxons/immutable
Move to immutable with Records
Diffstat (limited to 'frontend/src/redux/errors.js')
-rw-r--r--frontend/src/redux/errors.js22
1 files changed, 3 insertions, 19 deletions
diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js
index ec1e30b6..ad1e2795 100644
--- a/frontend/src/redux/errors.js
+++ b/frontend/src/redux/errors.js
@@ -1,4 +1,4 @@
-import Immutable from 'seamless-immutable';
+import ErrorsState from '../models/errors';
export const types = {
ERROR_RECEIVED_ON_WS: 'ERROR/RECEIVED_ON_WS',
@@ -11,27 +11,11 @@ export const actions = {
}),
};
-const initialState = Immutable.from({
- nextId: 0,
- history: [],
-});
-
-export default (state = initialState, action) => {
+export default (state = new ErrorsState(), action) => {
switch (action.type) {
case types.ERROR_RECEIVED_ON_WS:
- let error = Object.assign({ id: state.nextId, timestamp: new Date() }, action.error);
- let newState = state.set('nextId', state.nextId + 1);
- newState = addErrorToHistory(newState, error);
- return newState;
+ return state.addError(action.error);
default:
return state;
}
};
-
-function addErrorToHistory(state, error) {
- return addToArray(state, 'history', error);
-}
-
-function addToArray(state, arrayKey, element) {
- return state.set(arrayKey, state[arrayKey].concat([element]));
-}
bgstack15