diff --git a/packages/unleash-frontend-next/src/store/feature-actions.js b/packages/unleash-frontend-next/src/store/feature-actions.js index e73f49e22c..5b0361a52f 100644 --- a/packages/unleash-frontend-next/src/store/feature-actions.js +++ b/packages/unleash-frontend-next/src/store/feature-actions.js @@ -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), diff --git a/packages/unleash-frontend-next/src/store/feature-store.js b/packages/unleash-frontend-next/src/store/feature-store.js index 24a79bdf5f..6e0e9c7992 100644 --- a/packages/unleash-frontend-next/src/store/feature-store.js +++ b/packages/unleash-frontend-next/src/store/feature-store.js @@ -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; }