From 6b234ea7586aa9549a050de2e355a35da493d84e Mon Sep 17 00:00:00 2001 From: Gideon Pinto Date: Thu, 28 Mar 2024 10:41:36 -0400 Subject: [PATCH] fix: Ensure only the currently pulling study displays the 'pulling' activity (#1134) --- src/components/Pacs/components/SeriesCard.tsx | 11 +++++----- src/components/Pacs/components/StudyCard.tsx | 14 +++++++++---- src/components/Pacs/context/index.tsx | 20 ++++++++++++------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/Pacs/components/SeriesCard.tsx b/src/components/Pacs/components/SeriesCard.tsx index 7f2a57d32..dffc1f4ee 100644 --- a/src/components/Pacs/components/SeriesCard.tsx +++ b/src/components/Pacs/components/SeriesCard.tsx @@ -69,15 +69,16 @@ const SeriesCardCopy = ({ series }: { series: any }) => { const [isFetching, setIsFetching] = useState(false); const [openSeriesPreview, setOpenSeriesPreview] = useState(false); const [isPreviewFileAvailable, setIsPreviewFileAvailable] = useState(false); - const seriesInstances = parseInt(NumberOfSeriesRelatedInstances.value); + const studyInstanceUID = StudyInstanceUID.value; + const seriesInstanceUID = SeriesInstanceUID.value; const pullQuery: DataFetchQuery = useMemo(() => { return { - StudyInstanceUID: StudyInstanceUID.value, - SeriesInstanceUID: SeriesInstanceUID.value, + StudyInstanceUID: studyInstanceUID, + SeriesInstanceUID: seriesInstanceUID, }; - }, [SeriesInstanceUID.value]); + }, [studyInstanceUID, seriesInstanceUID]); const { data, isPending, isError, error } = useQuery({ queryKey: ["pacsFiles", SeriesInstanceUID.value], @@ -90,7 +91,7 @@ const SeriesCardCopy = ({ series }: { series: any }) => { }); useEffect(() => { - if (pullStudy && !isFetching) { + if (pullStudy?.[studyInstanceUID] && !isFetching) { handleRetrieve(); } }, [pullStudy]); diff --git a/src/components/Pacs/components/StudyCard.tsx b/src/components/Pacs/components/StudyCard.tsx index 3e0f0e8db..c2d321a33 100644 --- a/src/components/Pacs/components/StudyCard.tsx +++ b/src/components/Pacs/components/StudyCard.tsx @@ -21,7 +21,7 @@ import { import { PacsQueryContext, Types } from "../context"; import SeriesCard from "./SeriesCard"; import { CardHeaderComponent } from "./SettingsComponents"; -import { formatStudyDate } from "./utils"; + import useSettings from "../useSettings"; const StudyCardCopy = ({ study }: { study: any }) => { @@ -56,7 +56,10 @@ const StudyCardCopy = ({ study }: { study: any }) => { if (allSeriesBeingTracked) { dispatch({ type: Types.SET_PULL_STUDY, - payload: null, + payload: { + studyInstanceUID, + status: false, + }, }); } } @@ -218,7 +221,7 @@ const StudyCardCopy = ({ study }: { study: any }) => { /> - {pullStudy ? ( + {pullStudy[studyInstanceUID] ? ( ) : ( @@ -226,7 +229,10 @@ const StudyCardCopy = ({ study }: { study: any }) => { onClick={() => { dispatch({ type: Types.SET_PULL_STUDY, - payload: null, + payload: { + studyInstanceUID, + status: true, + }, }); setIsStudyExpanded(true); }} diff --git a/src/components/Pacs/context/index.tsx b/src/components/Pacs/context/index.tsx index 7e792e5be..216bc40ae 100644 --- a/src/components/Pacs/context/index.tsx +++ b/src/components/Pacs/context/index.tsx @@ -20,9 +20,7 @@ export enum Types { SET_LOADING_SPINNER = "SET_LOADING_SPINNER", SET_DEFAULT_EXPANDED = "SET_DEFAULT_EXPANDED", SET_SHOW_PREVIEW = "SET_SHOW_PREVIEW", - SET_PULL_STUDY = "SET_PULL_STUDY", - SET_STUDY_PULL_TRACKER = "SET_STUDY_PULL_TRACKER", } @@ -34,7 +32,9 @@ interface PacsQueryState { fetchingResults: { status: boolean; text: string }; shouldDefaultExpanded: boolean; preview: boolean; - pullStudy: boolean; + pullStudy: { + [key: string]: boolean; + }; studyPullTracker: { [key: string]: { [key: string]: boolean; @@ -50,7 +50,7 @@ const initialState = { fetchingResults: { status: false, text: "" }, shouldDefaultExpanded: false, preview: false, - pullStudy: false, + pullStudy: {}, studyPullTracker: {}, }; @@ -89,7 +89,10 @@ type PacsQueryPayload = { preview: boolean; }; - [Types.SET_PULL_STUDY]: null; + [Types.SET_PULL_STUDY]: { + studyInstanceUID: string; + status: boolean; + }; [Types.SET_STUDY_PULL_TRACKER]: { studyInstanceUID: string; @@ -183,12 +186,15 @@ const pacsQueryReducer = (state: PacsQueryState, action: PacsQueryActions) => { } case Types.SET_PULL_STUDY: { + const { studyInstanceUID, status } = action.payload; return { ...state, - pullStudy: !state.pullStudy, + pullStudy: { + ...state.pullStudy, + [studyInstanceUID]: status, + }, }; } - case Types.SET_STUDY_PULL_TRACKER: { const { studyInstanceUID, seriesInstanceUID, currentProgress } = action.payload;