Skip to content

Commit

Permalink
Merge pull request #344 from allen-cell-animated/fix/load-disabled-ch…
Browse files Browse the repository at this point in the history
…annels

- Channel load status is now tracked using `channelLoadedRef`, and checks for initial load are performed against it.
  - This allows channel LUTs to be initialized for channels that are initially disabled and later reenabled.
  • Loading branch information
ShrimpCryptid authored Dec 18, 2024
2 parents cc77aa3 + e728061 commit 63d6dab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/aics-image-viewer/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ const App: React.FC<AppProps> = (props) => {

// State for image loading/reloading

// `true` when this is the initial load of an image
const initialLoadRef = useRef(true);
/** `true` when a channel's data has been loaded for the current image. */
const hasChannelLoadedRef = useRef<boolean[]>([]);
// `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
Expand Down Expand Up @@ -258,7 +258,7 @@ const App: React.FC<AppProps> = (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)
Expand Down Expand Up @@ -309,14 +309,14 @@ const App: React.FC<AppProps> = (props) => {
if (aimg.channelNames[channelIndex] === getCurrentViewerChannelSettings()?.maskChannelName) {
view3d.setVolumeChannelAsMask(aimg, channelIndex);
}
hasChannelLoadedRef.current[channelIndex] = true;

// when any channel data has arrived:
setSendingQueryRequest(false);
setOneChannelLoaded(channelIndex);
if (aimg.isLoaded()) {
view3d.updateActiveChannels(aimg);
setImageLoaded(true);
initialLoadRef.current = false;
playControls.onImageLoaded();
}
};
Expand Down Expand Up @@ -400,7 +400,7 @@ const App: React.FC<AppProps> = (props) => {

setSendingQueryRequest(true);
setImageLoaded(false);
initialLoadRef.current = true;
hasChannelLoadedRef.current = [];

const loadSpec = new LoadSpec();
loadSpec.time = viewerState.current.time;
Expand Down

0 comments on commit 63d6dab

Please sign in to comment.