From ea2b87dfd35004f54e6db875785e73ca68b88b86 Mon Sep 17 00:00:00 2001 From: Konstantinos Paparas Date: Tue, 11 Feb 2025 13:50:17 +0100 Subject: [PATCH] fix: adjust integration to default to locally stored data (#276) This is to avoid having empty integrations if the network is slow --- composables/integrations.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/composables/integrations.ts b/composables/integrations.ts index a57f0724..8e6d4971 100644 --- a/composables/integrations.ts +++ b/composables/integrations.ts @@ -3,12 +3,6 @@ import { IntegrationData, type IntegrationItem } from '~/types/integrations'; import LocalIntegrationData from '~/public/integrations/all.json'; export const useIntegrationsData = createSharedComposable(() => { - const defaultData = () => ({ - blockchains: [], - exchanges: [], - protocols: [], - }); - const { public: { isDev, testing } } = useRuntimeConfig(); const getRemoteIntegrationData = async (): Promise => { @@ -57,16 +51,15 @@ export const useIntegrationsData = createSharedComposable(() => { }; const data = asyncComputed(async () => { - if (isDev) - return filterDuplicateData(LocalIntegrationData); - - const remoteData = await getRemoteIntegrationData(); - - if (remoteData) - return filterDuplicateData(remoteData); - - return defaultData(); - }, defaultData()); + let data: IntegrationData; + if (isDev) { + data = LocalIntegrationData; + } + else { + data = await getRemoteIntegrationData() ?? LocalIntegrationData; + } + return filterDuplicateData(data); + }, filterDuplicateData(LocalIntegrationData)); return { data,