From be6a04684b0c4d0d8687a3ebe760b5e185a878cc Mon Sep 17 00:00:00 2001 From: dannyrb Date: Tue, 16 Jun 2020 23:02:16 -0400 Subject: [PATCH] Don't try and "getImageSrc" for datasets without imageIds (DICOM SR) --- .../default/src/Panels/PanelStudyBrowser.jsx | 36 ++++++++++++------ .../PanelStudyBrowserTracking.jsx | 38 ++++++++++++------- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/extensions/default/src/Panels/PanelStudyBrowser.jsx b/extensions/default/src/Panels/PanelStudyBrowser.jsx index 5cf571ff8..e2647aca6 100644 --- a/extensions/default/src/Panels/PanelStudyBrowser.jsx +++ b/extensions/default/src/Panels/PanelStudyBrowser.jsx @@ -49,6 +49,7 @@ function PanelStudyBrowser({ } StudyInstanceUIDs.forEach(sid => fetchStudiesForPatient(sid)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [StudyInstanceUIDs, getStudiesForPatientByStudyInstanceUID]); // ~~ Initial Thumbnails @@ -62,12 +63,18 @@ function PanelStudyBrowser({ const imageIds = dataSource.getImageIdsForDisplaySet(displaySet); const imageId = imageIds[Math.floor(imageIds.length / 2)]; - // When the image arrives, render it and store the result in the thumbnailImgSrcMap - newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc(imageId); - setThumbnailImageSrcMap(prevState => { - return { ...prevState, ...newImageSrcEntry }; - }); + // TODO: Is it okay that imageIds are not returned here for SR displaysets? + if (imageId) { + // When the image arrives, render it and store the result in the thumbnailImgSrcMap + newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( + imageId + ); + setThumbnailImageSrcMap(prevState => { + return { ...prevState, ...newImageSrcEntry }; + }); + } }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); // ~~ displaySets @@ -80,6 +87,7 @@ function PanelStudyBrowser({ ); setDisplaySets(mappedDisplaySets); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [thumbnailImageSrcMap]); // ~~ subscriptions --> displaySets @@ -96,13 +104,16 @@ function PanelStudyBrowser({ const imageIds = dataSource.getImageIdsForDisplaySet(displaySet); const imageId = imageIds[Math.floor(imageIds.length / 2)]; - // When the image arrives, render it and store the result in the thumbnailImgSrcMap - newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( - imageId - ); - setThumbnailImageSrcMap(prevState => { - return { ...prevState, ...newImageSrcEntry }; - }); + // TODO: Is it okay that imageIds are not returned here for SR displaysets? + if (imageId) { + // When the image arrives, render it and store the result in the thumbnailImgSrcMap + newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( + imageId + ); + setThumbnailImageSrcMap(prevState => { + return { ...prevState, ...newImageSrcEntry }; + }); + } }); } ); @@ -125,6 +136,7 @@ function PanelStudyBrowser({ SubscriptionDisplaySetsAdded.unsubscribe(); SubscriptionDisplaySetsChanged.unsubscribe(); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const tabs = _createStudyBrowserTabs( diff --git a/extensions/measurement-tracking/src/panels/PanelStudyBrowserTracking/PanelStudyBrowserTracking.jsx b/extensions/measurement-tracking/src/panels/PanelStudyBrowserTracking/PanelStudyBrowserTracking.jsx index afc40e7b5..d33724702 100644 --- a/extensions/measurement-tracking/src/panels/PanelStudyBrowserTracking/PanelStudyBrowserTracking.jsx +++ b/extensions/measurement-tracking/src/panels/PanelStudyBrowserTracking/PanelStudyBrowserTracking.jsx @@ -54,6 +54,7 @@ function PanelStudyBrowserTracking({ ); return unsubscribe; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [MeasurementService, activeViewportIndex, sendTrackedMeasurementsEvent]); const { trackedStudy, trackedSeries } = trackedMeasurements.context; @@ -82,6 +83,7 @@ function PanelStudyBrowserTracking({ } StudyInstanceUIDs.forEach(sid => fetchStudiesForPatient(sid)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [StudyInstanceUIDs, getStudiesForPatientByStudyInstanceUID]); // ~~ Initial Thumbnails @@ -95,12 +97,18 @@ function PanelStudyBrowserTracking({ const imageIds = dataSource.getImageIdsForDisplaySet(displaySet); const imageId = imageIds[Math.floor(imageIds.length / 2)]; - // When the image arrives, render it and store the result in the thumbnailImgSrcMap - newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc(imageId); - setThumbnailImageSrcMap(prevState => { - return { ...prevState, ...newImageSrcEntry }; - }); + // TODO: Is it okay that imageIds are not returned here for SR displaysets? + if (imageId) { + // When the image arrives, render it and store the result in the thumbnailImgSrcMap + newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( + imageId + ); + setThumbnailImageSrcMap(prevState => { + return { ...prevState, ...newImageSrcEntry }; + }); + } }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [DisplaySetService, dataSource, getImageSrc]); // ~~ displaySets @@ -115,6 +123,7 @@ function PanelStudyBrowserTracking({ ); setDisplaySets(mappedDisplaySets); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ DisplaySetService.activeDisplaySets, trackedSeries, @@ -135,14 +144,16 @@ function PanelStudyBrowserTracking({ ); const imageIds = dataSource.getImageIdsForDisplaySet(displaySet); const imageId = imageIds[Math.floor(imageIds.length / 2)]; - - // When the image arrives, render it and store the result in the thumbnailImgSrcMap - newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( - imageId - ); - setThumbnailImageSrcMap(prevState => { - return { ...prevState, ...newImageSrcEntry }; - }); + // TODO: Is it okay that imageIds are not returned here for SR displaysets? + if (imageId) { + // When the image arrives, render it and store the result in the thumbnailImgSrcMap + newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc( + imageId + ); + setThumbnailImageSrcMap(prevState => { + return { ...prevState, ...newImageSrcEntry }; + }); + } }); } ); @@ -167,6 +178,7 @@ function PanelStudyBrowserTracking({ SubscriptionDisplaySetsAdded.unsubscribe(); SubscriptionDisplaySetsChanged.unsubscribe(); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ DisplaySetService, dataSource,