Skip to content

Commit

Permalink
Take a less agressive path when requesting user datasets from within …
Browse files Browse the repository at this point in the history
…eda (#1175)

(cherry picked from commit 4e43bf9)
  • Loading branch information
dmfalke committed Sep 17, 2024
1 parent 05e50e8 commit 0182918
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
15 changes: 8 additions & 7 deletions packages/libs/eda/src/lib/workspace/AllAnalyses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { map, orderBy } from 'lodash';
import Path from 'path';
import { Link, useHistory, useLocation } from 'react-router-dom';

import { useWdkServiceWithVdi } from '@veupathdb/user-datasets/lib/Hooks/wdkServiceWithVdi';
import { isVdiCompatibleWdkService } from '@veupathdb/user-datasets/lib/Service';

import {
Button,
Expand Down Expand Up @@ -185,14 +185,15 @@ export function AllAnalyses(props: Props) {
});

const [ownUserDatasets, communityDatasets] =
useWdkServiceWithVdi(
(wdkService) =>
Promise.all([
useWdkService(async (wdkService) => {
if (isVdiCompatibleWdkService(wdkService)) {
return Promise.all([
wdkService.getCurrentUserDatasets(),
wdkService.getCommunityDatasets(),
]),
[]
) ?? [];
]);
}
return [];
}, []) ?? [];

const { analyses, deleteAnalyses, updateAnalysis, loading, error } =
useAnalysisList(analysisClient);
Expand Down
12 changes: 7 additions & 5 deletions packages/libs/eda/src/lib/workspace/PublicAnalysesRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { useWdkStudyRecords } from '../core/hooks/study';

import { PublicAnalyses, StudyRecordMetadata } from './PublicAnalyses';
import SubsettingClient from '../core/api/SubsettingClient';
import { useWdkServiceWithVdi } from '@veupathdb/user-datasets/lib/Hooks/wdkServiceWithVdi';
import { isVdiCompatibleWdkService } from '@veupathdb/user-datasets/lib/Service';
import { map } from 'lodash';
import { getStudyId } from '@veupathdb/study-data-access/lib/shared/studies';
import { diyUserDatasetIdToWdkRecordId } from '@veupathdb/user-datasets/lib/Utils/diyDatasets';
import { useWdkService } from '@veupathdb/wdk-client/lib/Hooks/WdkServiceHook';

export interface Props {
analysisClient: AnalysisClient;
Expand All @@ -28,10 +29,11 @@ export function PublicAnalysesRoute({
}: Props) {
const publicAnalysisListState = usePublicAnalysisList(analysisClient);
const studyRecords = useWdkStudyRecords(subsettingClient);
const communityDatasets = useWdkServiceWithVdi(
(wdkService) => wdkService.getCommunityDatasets(),
[]
);
const communityDatasets = useWdkService(async (wdkService) => {
if (isVdiCompatibleWdkService(wdkService))
return wdkService.getCommunityDatasets();
return [];
}, []);

const studyRecordsMetadata: StudyRecordMetadata[] | undefined =
studyRecords &&
Expand Down
18 changes: 0 additions & 18 deletions packages/libs/user-datasets/src/lib/Hooks/wdkServiceWithVdi.ts

This file was deleted.

0 comments on commit 0182918

Please sign in to comment.