1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fixed bugs

This commit is contained in:
ivaosthu 2016-10-20 17:09:04 +02:00 committed by Ivar Conradi Østhus
parent 13f722bcaa
commit 0f7ac32ca1
2 changed files with 9 additions and 4 deletions

View File

@ -58,6 +58,7 @@ function requestFeatureToggles () {
}
function receiveFeatureToggles (json) {
debug('reviced feature toggles', json);
return {
type: RECEIVE_FEATURE_TOGGLES,
featureToggles: json.features.map(features => features),

View File

@ -1,4 +1,5 @@
import { List, Map as $Map } from 'immutable';
const debug = require('debug')('unleash:feature-store');
import {
@ -11,17 +12,20 @@ import {
const features = (state = new List([]), action) => {
switch (action.type) {
case ADD_FEATURE_TOGGLE:
debug(ADD_FEATURE_TOGGLE, action);
return state.push(new $Map(action.featureToggle));
case UPDATE_FEATURE_TOGGLE:
return state.$Map(t => {
if (t.get('name') === action.featureToggle.name) {
debug(UPDATE_FEATURE_TOGGLE, action);
return state.map(toggle => {
if (toggle.get('name') === action.featureToggle.name) {
return new $Map(action.featureToggle);
} else {
return t;
return toggle;
}
});
case RECEIVE_FEATURE_TOGGLES:
return new List(action.featureToggles.$Map(t => new $Map(t)));
debug(RECEIVE_FEATURE_TOGGLES, action);
return new List(action.featureToggles.map($Map));
default:
return state;
}