fix: upload and refresh patient list

This commit is contained in:
mozzie 2024-09-18 10:52:08 +08:00
parent 039325b768
commit c52b3f1e00
2 changed files with 14 additions and 2 deletions

View File

@ -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 () => {

View File

@ -23,7 +23,7 @@ export const Datasource = () => {
const [selectedStudyId, setSelectedStudyId] = useState<string | null>(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) => {