1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-27 00:19:39 +01:00
unleash.unleash/packages/unleash-frontend-next/src/store/error-store.js
2020-02-20 08:30:33 +01:00

29 lines
843 B
JavaScript

import { List, Map as $Map } from 'immutable';
import { ERROR_RECEIVE_FEATURE_TOGGLES } from './feature-actions';
import { MUTE_ERRORS } from './error-actions';
const debug = require('debug')('unleash:error-store');
function getInitState () {
return new $Map({
list: new List(),
showError: false,
});
}
const strategies = (state = getInitState(), action) => {
switch (action.type) {
case ERROR_RECEIVE_FEATURE_TOGGLES:
debug('Got error', action);
return state
.update('list', (list) => list.push('Failed fetching feature toggles'))
.set('showError', true);
case MUTE_ERRORS:
debug('muting errors');
return state.set('showError', false);
default:
return state;
}
};
export default strategies;