From fb1b47b9c928c5fe38aef8138a131c7554a89d86 Mon Sep 17 00:00:00 2001 From: dannyrb Date: Wed, 13 May 2020 00:32:26 -0400 Subject: [PATCH] Hook to query for series data --- .../StudyListContainer/StudyListContainer.jsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/platform/viewer/src/routes/StudyListContainer/StudyListContainer.jsx b/platform/viewer/src/routes/StudyListContainer/StudyListContainer.jsx index c0997f301..5e87327c8 100644 --- a/platform/viewer/src/routes/StudyListContainer/StudyListContainer.jsx +++ b/platform/viewer/src/routes/StudyListContainer/StudyListContainer.jsx @@ -113,27 +113,27 @@ function StudyListContainer({ history, data: studies, dataSource }) { useEffect(() => { const fetchSeries = async studyInstanceUid => { try { - const expandedStudiesSeriesList = {}; + const result = await dataSource.query.series.search(studyInstanceUid); - expandedStudiesSeriesList[ - studyInstanceUid - ] = await dataSource.query.series.search(studyInstanceUid); - - setSeriesInStudies( - Object.assign({}, seriesInStudies, expandedStudiesSeriesList) - ); + seriesInStudiesMap.set(studyInstanceUid, result); + setStudiesWithSeriesData([...studiesWithSeriesData, studyInstanceUid]); } catch (ex) { // TODO: UI Notification Service console.warn(ex); } }; + // TODO: WHY WOULD YOU USE AN INDEX OF 1?! + // Note: expanded rows index begins at 1 for (let z = 0; z < expandedRows.length; z++) { - const studyInstanceUid = studies[z].studyInstanceUid; - if (seriesInStudies[studyInstanceUid]) { + const expandedRowIndex = expandedRows[z] - 1; + console.log(sortedStudies[expandedRowIndex]); + const studyInstanceUid = sortedStudies[expandedRowIndex].studyInstanceUid; + if (studiesWithSeriesData.includes(studyInstanceUid)) { continue; } + console.log(`fetching for ${expandedRowIndex}`) fetchSeries(studyInstanceUid); } // eslint-disable-next-line react-hooks/exhaustive-deps