diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-28 22:18:26 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-28 22:18:26 +0200 |
commit | 5e07cdaaf0aa37298a5ed72a35519d21c9be6069 (patch) | |
tree | ded13a3acfa72b4c70fee9cc623c2fc7d1dda334 /frontend | |
parent | Merge pull request #14 from luxons/immutable (diff) | |
download | seven-wonders-5e07cdaaf0aa37298a5ed72a35519d21c9be6069.tar.gz seven-wonders-5e07cdaaf0aa37298a5ed72a35519d21c9be6069.tar.bz2 seven-wonders-5e07cdaaf0aa37298a5ed72a35519d21c9be6069.zip |
Remove error history from the state
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/src/models/errors.js | 34 | ||||
-rw-r--r-- | frontend/src/reducers.js | 2 | ||||
-rw-r--r-- | frontend/src/redux/errors.js | 21 | ||||
-rw-r--r-- | frontend/src/sagas/errors.js | 6 |
4 files changed, 1 insertions, 62 deletions
diff --git a/frontend/src/models/errors.js b/frontend/src/models/errors.js deleted file mode 100644 index c00954cd..00000000 --- a/frontend/src/models/errors.js +++ /dev/null @@ -1,34 +0,0 @@ -import { Record, List } from 'immutable'; - -const ErrorsRecord = Record({ - nextId: 0, - history: new List(), -}); - -export default class ErrorsState extends ErrorsRecord { - addError(error) { - const errorObject = new Error({ id: this.nextId, error: new ErrorBag(error) }); - return this.set('history', this.history.push(errorObject)).set('nextId', this.nextId + 1); - } -} - -const ErrorRecord = Record({ - id: -1, - timestamp: new Date(), - error: new ErrorsRecord(), -}); - -export class Error extends ErrorRecord {} - -const ErrorBagRecord = Record({ - type: '', - position: 'bottom-left', - options: { - icon: 'error', - removeOnHover: true, - showCloseButton: true, - }, - title: 'Unknown Error', -}); - -export class ErrorBag extends ErrorBagRecord {} diff --git a/frontend/src/reducers.js b/frontend/src/reducers.js index 4b98a9ca..8a4c3083 100644 --- a/frontend/src/reducers.js +++ b/frontend/src/reducers.js @@ -2,13 +2,11 @@ import { combineReducers } from 'redux-immutable'; import { routerReducer } from 'react-router-redux'; import { reducer as toastrReducer } from 'react-redux-toastr'; -import errorsReducer from './redux/errors'; import gamesReducer from './redux/games'; import playersReducer from './redux/players'; export default function createReducer() { return combineReducers({ - errors: errorsReducer, games: gamesReducer, players: playersReducer, routing: routerReducer, diff --git a/frontend/src/redux/errors.js b/frontend/src/redux/errors.js deleted file mode 100644 index ad1e2795..00000000 --- a/frontend/src/redux/errors.js +++ /dev/null @@ -1,21 +0,0 @@ -import ErrorsState from '../models/errors'; - -export const types = { - ERROR_RECEIVED_ON_WS: 'ERROR/RECEIVED_ON_WS', -}; - -export const actions = { - errorReceived: error => ({ - type: types.ERROR_RECEIVED_ON_WS, - error, - }), -}; - -export default (state = new ErrorsState(), action) => { - switch (action.type) { - case types.ERROR_RECEIVED_ON_WS: - return state.addError(action.error); - default: - return state; - } -}; diff --git a/frontend/src/sagas/errors.js b/frontend/src/sagas/errors.js index 41eb6902..e43875ae 100644 --- a/frontend/src/sagas/errors.js +++ b/frontend/src/sagas/errors.js @@ -1,8 +1,5 @@ -import { apply, call, cancelled, put, take } from 'redux-saga/effects'; - +import { apply, call, cancelled, take } from 'redux-saga/effects'; import { createSubscriptionChannel } from '../utils/websocket'; -import { actions } from '../redux/errors'; - import { toastr } from 'react-redux-toastr'; export default function* errorHandlingSaga({ socket }) { @@ -24,7 +21,6 @@ function* handleOneError(err) { console.error('Error received on web socket channel', err); const msg = buildMsg(err); yield apply(toastr, toastr.error, [msg, { icon: 'error' }]); - yield put(actions.errorReceived(err)); } function buildMsg(err) { |