66
77import { PageSection } from "@patternfly/react-core" ;
88import config from "config" ;
9- import { access } from "fs" ;
109import { useEffect , useState } from "react" ;
1110import {
1211 genUUID ,
13- getRoot ,
14- getRootID ,
1512 getState ,
1613 type ModuleToFunc ,
1714 StateType ,
@@ -26,8 +23,7 @@ import PacsLoadingScreen from "./components/PacsLoadingScreen.tsx";
2623import { DEFAULT_PREFERENCES } from "./defaultPreferences.ts" ;
2724import styles from "./PacsApp.module.css" ;
2825import PacsView from "./PacsView.tsx" ;
29- import { type PacsState , QUERY_PROMPT , SearchMode } from "./types.ts" ;
30- import { createFeedWithSeriesInstanceUID , errorCodeIsNot4xx } from "./utils.ts" ;
26+ import type { PacsState } from "./types.ts" ;
3127
3228type TDoPacs = ModuleToFunc < typeof DoPacs > ;
3329
@@ -189,7 +185,7 @@ export default () => {
189185 ] ) ;
190186
191187 // Subscribe to all expanded series
192- // biome-ignore lint/correctness/useExhaustiveDependencies: updateReceiveState
188+ console . info ( "PacsApp: isExpandedAllDone:" , isExpandedAllDone , "pacs:" , pacs ) ;
193189 useEffect ( ( ) => {
194190 if ( wsError ) {
195191 return ;
@@ -209,6 +205,7 @@ export default () => {
209205
210206 const url = `${ config . API_ROOT } /pacs/sse/?pacs_name=${ service } &series_uids=${ series_uids } ` ;
211207 const eventSource = new EventSource ( url ) ;
208+ console . info ( "PacsApp.eventSource: new eventSource" ) ;
212209
213210 eventSource . onmessage = ( event ) => {
214211 const data : Lonk < LonkMessageData > = JSON . parse ( event . data ) ;
@@ -217,7 +214,11 @@ export default () => {
217214
218215 eventSource . onerror = ( err ) => {
219216 console . error ( "PacsApp.eventSource.onerror: err:" , err ) ;
220- setWsError ( `event error: ${ err } ` ) ;
217+ // XXX TODO: error handling.
218+ // It's possible that the error happens when isExpandedAllDone is already done.
219+ // but the useEffect is not refreshed yet.
220+ // However, it seems like we cannot detect this here because it's a function
221+ // created in the past.
221222 } ;
222223
223224 return ( ) => {
@@ -226,7 +227,7 @@ export default () => {
226227 } ;
227228 // Note: we are subscribing to series, but never unsubscribing.
228229 // This is mostly harmless.
229- } , [ expandedSeries , wsError , isExpandedAllDone ] ) ;
230+ } , [ pacsID , service , expandedSeries , wsError , isExpandedAllDone , doPacs ] ) ;
230231
231232 // ========================================
232233 // RENDER
0 commit comments