diff --git a/app/src/lib/stores/featureFlags.ts b/app/src/lib/stores/featureFlags.ts index bf9c291..f490a57 100644 --- a/app/src/lib/stores/featureFlags.ts +++ b/app/src/lib/stores/featureFlags.ts @@ -1,9 +1,9 @@ -import { api } from '$lib/api' import { notifications } from '$lib/components/toasts/notifications' import Kinematic from '$lib/kinematic' import { persistentStore } from '$lib/utilities' import { derived, type Writable } from 'svelte/store' import { resolve } from '$app/paths' +import { socket } from '$lib/stores' let featureFlagsStore: Writable> @@ -11,12 +11,20 @@ export function useFeatureFlags() { if (!featureFlagsStore) { featureFlagsStore = persistentStore>('FeatureFlags', {}) - api.get>('/api/features').then(result => { - if (result.isOk()) featureFlagsStore.set(result.inner) - else { - notifications.error('Feature flag could not be fetched', 2500) - } - }) + socket + .request({ featuresDataRequest: {} }) + .then(response => { + if (response.featuresDataResponse) { + featureFlagsStore.set( + response.featuresDataResponse as unknown as Record + ) + } else { + notifications.error('Feature flags could not be fetched', 2500) + } + }) + .catch(() => { + notifications.error('Feature flags could not be fetched', 2500) + }) } return featureFlagsStore