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.js33
1 files changed, 18 insertions, 15 deletions
diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js
index 7d113db1..eb807fdc 100644
--- a/frontend/src/redux/errors.js
+++ b/frontend/src/redux/errors.js
@@ -1,37 +1,40 @@
-import Immutable from 'seamless-immutable'
+import Immutable from "seamless-immutable";
export const types = {
- ERROR_RECEIVED_ON_WS: 'ERROR/RECEIVED_ON_WS',
-}
+ ERROR_RECEIVED_ON_WS: "ERROR/RECEIVED_ON_WS"
+};
export const actions = {
- errorReceived: (error) => ({
+ errorReceived: error => ({
type: types.ERROR_RECEIVED_ON_WS,
error
- }),
-}
+ })
+};
const initialState = Immutable.from({
nextId: 0,
history: []
-})
+});
export default (state = initialState, 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
+ 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
+ return state;
}
-}
+};
function addErrorToHistory(state, error) {
- return addToArray(state, 'history', error);
+ return addToArray(state, "history", error);
}
function addToArray(state, arrayKey, element) {
- return state.set(arrayKey, state[arrayKey].concat([ element ]));
+ return state.set(arrayKey, state[arrayKey].concat([element]));
}
bgstack15