Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust integration to default to locally stored data #276

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions composables/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntegrationData | null> => {
Expand Down Expand Up @@ -57,16 +51,15 @@ export const useIntegrationsData = createSharedComposable(() => {
};

const data = asyncComputed<IntegrationData>(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,
Expand Down
Loading