summaryrefslogtreecommitdiff
path: root/frontend/src/redux/errors.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/redux/errors.js')
-rw-r--r--frontend/src/redux/errors.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js
index 1c247955..7d113db1 100644
--- a/frontend/src/redux/errors.js
+++ b/frontend/src/redux/errors.js
@@ -8,16 +8,30 @@ export const actions = {
errorReceived: (error) => ({
type: types.ERROR_RECEIVED_ON_WS,
error
- })
+ }),
}
-const initialState = Immutable.from([])
+const initialState = Immutable.from({
+ nextId: 0,
+ history: []
+})
export default (state = initialState, action) => {
switch (action.type) {
case types.ERROR_RECEIVED_ON_WS:
- return state.concat([ action.error ])
+ 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
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