From 59b927e9adfde0638eb5146dd371a81e381c6d1c Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 14 Apr 2026 01:38:44 +0200 Subject: [PATCH] Refactor applyControlEffectToResolvedState in control-surface.ts --- src/controls/control-surface.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/controls/control-surface.ts b/src/controls/control-surface.ts index fe258235..6d6d7cb8 100644 --- a/src/controls/control-surface.ts +++ b/src/controls/control-surface.ts @@ -897,19 +897,23 @@ export function applyControlEffectToResolvedState( return nextResolved; } case "setLightIntensity": { - const nextValue = createResolvedLightIntensityChannelValue({ - descriptor: createLightIntensityControlChannelDescriptor({ - target: effect.target, - defaultValue: effect.intensity - }), - value: effect.intensity, - source + const nextDescriptor = createLightIntensityControlChannelDescriptor({ + target: effect.target, + defaultValue: effect.intensity }); - const descriptorKey = getControlChannelDescriptorKey(nextValue.descriptor); + const descriptorKey = getControlChannelDescriptorKey(nextDescriptor); const existingIndex = nextResolved.channels.findIndex( (candidate) => getControlChannelDescriptorKey(candidate.descriptor) === descriptorKey ); + const nextValue = createResolvedLightIntensityChannelValue({ + descriptor: + existingIndex >= 0 + ? nextResolved.channels[existingIndex].descriptor + : nextDescriptor, + value: effect.intensity, + source + }); if (existingIndex >= 0) { nextResolved.channels[existingIndex] = nextValue;