diff options
Diffstat (limited to 'frontend/src/redux/errors.js')
-rw-r--r-- | frontend/src/redux/errors.js | 22 |
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])); -} |