mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-27 00:19:39 +01:00
29 lines
843 B
JavaScript
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;
|