fix(modes): don't attempt to retrieve a stage index if HPs are an array (#4542)

This commit is contained in:
Ibrahim 2024-11-22 14:46:31 -05:00 committed by GitHub
parent 900a265637
commit 44648eef92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -218,11 +218,11 @@ export default function ModeRoute({
: hangingProtocol;
// Determine the index of the stageId if the hangingProtocolIdToUse is defined
const stageIndex = hangingProtocolIdToUse
? hangingProtocolService.getStageIndex(hangingProtocolIdToUse, {
const stageIndex = Array.isArray(hangingProtocolIdToUse)
? -1
: hangingProtocolService.getStageIndex(hangingProtocolIdToUse, {
stageId: runTimeStageId || undefined,
})
: -1;
});
// Ensure that the stage index is never negative
// If stageIndex is negative (e.g., if stage wasn't found), use 0 as the default
const stageIndexToUse = Math.max(0, stageIndex);