From 57246c36bdfbd0b78c09a2936f88cc31af2ed3fd Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Tue, 17 Dec 2024 13:40:31 -0800 Subject: [PATCH 1/2] fix: Track channel load status individually --- src/aics-image-viewer/components/App/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aics-image-viewer/components/App/index.tsx b/src/aics-image-viewer/components/App/index.tsx index 4d1f5ac6..5191b4ec 100644 --- a/src/aics-image-viewer/components/App/index.tsx +++ b/src/aics-image-viewer/components/App/index.tsx @@ -187,7 +187,7 @@ const App: React.FC = (props) => { // State for image loading/reloading // `true` when this is the initial load of an image - const initialLoadRef = useRef(true); + const hasChannelLoadedRef = useRef([]); // `true` when image data has been requested, but no data has been received yet const [sendingQueryRequest, setSendingQueryRequest] = useState(false); // `true` when all channels of the current image are loaded @@ -258,7 +258,7 @@ const App: React.FC = (props) => { // If this is the first load of this image, auto-generate initial LUTs if ( - initialLoadRef.current || + !hasChannelLoadedRef.current[channelIndex] || !thisChannelsSettings.controlPoints || !thisChannelsSettings.ramp || getChannelsAwaitingResetOnLoad().has(channelIndex) @@ -309,6 +309,7 @@ const App: React.FC = (props) => { if (aimg.channelNames[channelIndex] === getCurrentViewerChannelSettings()?.maskChannelName) { view3d.setVolumeChannelAsMask(aimg, channelIndex); } + hasChannelLoadedRef.current[channelIndex] = true; // when any channel data has arrived: setSendingQueryRequest(false); @@ -316,7 +317,6 @@ const App: React.FC = (props) => { if (aimg.isLoaded()) { view3d.updateActiveChannels(aimg); setImageLoaded(true); - initialLoadRef.current = false; playControls.onImageLoaded(); } }; @@ -400,7 +400,7 @@ const App: React.FC = (props) => { setSendingQueryRequest(true); setImageLoaded(false); - initialLoadRef.current = true; + hasChannelLoadedRef.current = []; const loadSpec = new LoadSpec(); loadSpec.time = viewerState.current.time; From e72806175fbad35fbf721b0e101643e84526f31b Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Tue, 17 Dec 2024 14:04:06 -0800 Subject: [PATCH 2/2] refactor: Update comment for `hasChannelLoadedRef` --- src/aics-image-viewer/components/App/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aics-image-viewer/components/App/index.tsx b/src/aics-image-viewer/components/App/index.tsx index 5191b4ec..cc076876 100644 --- a/src/aics-image-viewer/components/App/index.tsx +++ b/src/aics-image-viewer/components/App/index.tsx @@ -186,7 +186,7 @@ const App: React.FC = (props) => { // State for image loading/reloading - // `true` when this is the initial load of an image + /** `true` when a channel's data has been loaded for the current image. */ const hasChannelLoadedRef = useRef([]); // `true` when image data has been requested, but no data has been received yet const [sendingQueryRequest, setSendingQueryRequest] = useState(false);