Skip to content

Commit

Permalink
fix: Ensure only the currently pulling study displays the 'pulling' a…
Browse files Browse the repository at this point in the history
…ctivity (FNNDSC#1134)
  • Loading branch information
PintoGideon authored Mar 28, 2024
1 parent ca69b7a commit 6b234ea
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
11 changes: 6 additions & 5 deletions src/components/Pacs/components/SeriesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -90,7 +91,7 @@ const SeriesCardCopy = ({ series }: { series: any }) => {
});

useEffect(() => {
if (pullStudy && !isFetching) {
if (pullStudy?.[studyInstanceUID] && !isFetching) {
handleRetrieve();
}
}, [pullStudy]);
Expand Down
14 changes: 10 additions & 4 deletions src/components/Pacs/components/StudyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -56,7 +56,10 @@ const StudyCardCopy = ({ study }: { study: any }) => {
if (allSeriesBeingTracked) {
dispatch({
type: Types.SET_PULL_STUDY,
payload: null,
payload: {
studyInstanceUID,
status: false,
},
});
}
}
Expand Down Expand Up @@ -218,15 +221,18 @@ const StudyCardCopy = ({ study }: { study: any }) => {
/>
</Tooltip>

{pullStudy ? (
{pullStudy[studyInstanceUID] ? (
<DotsIndicator title="Pulling Study..." />
) : (
<Tooltip content="Pull Study">
<Button
onClick={() => {
dispatch({
type: Types.SET_PULL_STUDY,
payload: null,
payload: {
studyInstanceUID,
status: true,
},
});
setIsStudyExpanded(true);
}}
Expand Down
20 changes: 13 additions & 7 deletions src/components/Pacs/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand All @@ -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;
Expand All @@ -50,7 +50,7 @@ const initialState = {
fetchingResults: { status: false, text: "" },
shouldDefaultExpanded: false,
preview: false,
pullStudy: false,
pullStudy: {},
studyPullTracker: {},
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6b234ea

Please sign in to comment.