diff --git a/frontend/common/stores/feature-list-store.ts b/frontend/common/stores/feature-list-store.ts index d833f865aa9a..b2067cf5695b 100644 --- a/frontend/common/stores/feature-list-store.ts +++ b/frontend/common/stores/feature-list-store.ts @@ -36,23 +36,6 @@ import { getFeatureStates } from 'common/services/useFeatureState' import { getSegments } from 'common/services/useSegment' let createdFirstFeature = false const PAGE_SIZE = 50 -function recursivePageGet(url, parentRes) { - return data.get(url).then((res) => { - let response - if (parentRes) { - response = { - ...parentRes, - results: parentRes.results.concat(res.results), - } - } else { - response = res - } - if (res.next) { - return recursivePageGet(res.next, response) - } - return Promise.resolve(response) - }) -} const convertSegmentOverrideToFeatureState = ( override, @@ -129,15 +112,15 @@ const controller = { .then(() => Promise.all([ data.get(`${Project.api}projects/${projectId}/features/`), - data.get( - `${Project.api}environments/${environmentId}/featurestates/`, - ), - ]).then(([features, environmentFeatures]) => { + ]).then(([features]) => { + const environmentFeatures = features.results.map((v) => ({ + ...v.environment_feature_state, + feature: v.id, + })) store.model = { features: features.results, keyedEnvironmentFeatures: - environmentFeatures && - _.keyBy(environmentFeatures.results, 'feature'), + environmentFeatures && _.keyBy(environmentFeatures, 'feature'), } store.model.lastSaved = new Date().valueOf() store.saved({ createdFlag: flag.name }) @@ -863,16 +846,17 @@ const controller = { return Promise.all([ data.get(featuresEndpoint), - recursivePageGet( - `${Project.api}environments/${environmentId}/featurestates/?page_size=${PAGE_SIZE}`, - ), feature ? data.get( `${Project.api}projects/${projectId}/features/${feature}/`, ) : Promise.resolve(), ]) - .then(([features, environmentFeatures, feature]) => { + .then(([features, feature]) => { + const environmentFeatures = features.results.map((v) => ({ + ...v.environment_feature_state, + feature: v.id, + })) if (store.filter !== filter) { //The filter has been changed since, ignore the api response. This will be resolved when moving to RTK. return @@ -904,9 +888,10 @@ const controller = { store.model = { features: features.results.map(controller.parseFlag), - keyedEnvironmentFeatures: - environmentFeatures.results && - _.keyBy(environmentFeatures.results, 'feature'), + keyedEnvironmentFeatures: _.keyBy( + environmentFeatures, + 'feature', + ), } store.loaded() })