From c52b3f1e004401b137148e50afe6b29f0a3fe862 Mon Sep 17 00:00:00 2001 From: mozzie Date: Wed, 18 Sep 2024 10:52:08 +0800 Subject: [PATCH] fix: upload and refresh patient list --- apps/desktop/electron/ipcEvent/dicom/handler.ts | 3 ++- apps/desktop/src/pages/Datasource/index.tsx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/desktop/electron/ipcEvent/dicom/handler.ts b/apps/desktop/electron/ipcEvent/dicom/handler.ts index 36529f0..84decd1 100644 --- a/apps/desktop/electron/ipcEvent/dicom/handler.ts +++ b/apps/desktop/electron/ipcEvent/dicom/handler.ts @@ -8,11 +8,12 @@ export const registerDicomHandler = () => { const dia = await dialog.showOpenDialog({ properties: ["openDirectory"] }); if (dia.canceled) return null; const dcmPaths = await filterDicoms(dia.filePaths[0]); - uploadFilesInBatches({ + await uploadFilesInBatches({ filePaths: dcmPaths, batchSize: 6, feedback: (d) => event.reply("dicom:upload:detail", d), }); + event.reply("dicom:upload:finished"); // 重新刷新病人列表 }); ipcMain.handle("dicom:select", async () => { diff --git a/apps/desktop/src/pages/Datasource/index.tsx b/apps/desktop/src/pages/Datasource/index.tsx index 85351f5..62aba4a 100644 --- a/apps/desktop/src/pages/Datasource/index.tsx +++ b/apps/desktop/src/pages/Datasource/index.tsx @@ -23,7 +23,7 @@ export const Datasource = () => { const [selectedStudyId, setSelectedStudyId] = useState(null); const navigate = useNavigate(); - useEffect(() => { + const fetchPatients = () => { window.ipcRenderer .invoke("dicom:select") .then((patients: PatientInfo[]) => { @@ -31,6 +31,17 @@ export const Datasource = () => { rawPatientsRef.current = patients; setPatients(patients); }); + }; + + useEffect(() => { + fetchPatients(); + }, []); + + useEffect(() => { + window.ipcRenderer.on("dicom:upload:finished", fetchPatients); + return () => { + window.ipcRenderer.off("dicom:upload:finished", fetchPatients); + }; }, []); const handlePatientSearch = (filterValue: string) => {