export function fetchFeaturesConfig()

in src/utils/FEATURE.ts [37:55]


export function fetchFeaturesConfig(onDone: () => void): void {
  fetch(apiHttp('/features'))
    .then((response) => (response.status === 200 ? response.json() : Promise.resolve(null)))
    .then((values: Record<keyof FeatureFlags, boolean>) => {
      const featureKeys = Object.keys(FEATURE_FLAGS);
      if (values) {
        Object.keys(values).forEach((key) => {
          const fixedKey = key.split('_').slice(1, key.split('_').length).join('_');
          if (featureKeys.indexOf(fixedKey) > -1) {
            FEATURE_FLAGS[fixedKey as keyof FeatureFlags] = values[key as keyof FeatureFlags];
          }
        });
      }
      onDone();
    })
    .catch(() => {
      onDone();
    });
}