fix: add nullish coalescing to parameter dialogs

Fixed "Cannot read properties of undefined (reading 'toFixed')" errors
in TimeBasedParameterDialog and DynamicsParameterDialog by adding
nullish coalescing operators with default values to all parameter
accesses. This prevents errors when loading presets that have partial
parameter sets.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-17 20:50:48 +01:00
parent 8a0bd46593
commit 2fc1620495
2 changed files with 45 additions and 45 deletions

View File

@@ -371,11 +371,11 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Threshold</span>
<span className="text-muted-foreground font-mono">
{parameters.threshold.toFixed(1)} dB
{(parameters.threshold ?? -20).toFixed(1)} dB
</span>
</label>
<Slider
value={[parameters.threshold]}
value={[(parameters.threshold ?? -20)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, threshold: value }))
}
@@ -396,11 +396,11 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Ratio</span>
<span className="text-muted-foreground font-mono">
{(parameters as CompressorParameters | GateParameters).ratio.toFixed(1)}:1
{((parameters as CompressorParameters | GateParameters).ratio ?? 4).toFixed(1)}:1
</span>
</label>
<Slider
value={[(parameters as CompressorParameters | GateParameters).ratio]}
value={[((parameters as CompressorParameters | GateParameters).ratio ?? 4)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, ratio: value }))
}
@@ -421,11 +421,11 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Attack</span>
<span className="text-muted-foreground font-mono">
{parameters.attack.toFixed(2)} ms
{(parameters.attack ?? 5).toFixed(2)} ms
</span>
</label>
<Slider
value={[Math.log10(parameters.attack)]}
value={[Math.log10(parameters.attack ?? 5)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, attack: Math.pow(10, value) }))
}
@@ -445,11 +445,11 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Release</span>
<span className="text-muted-foreground font-mono">
{parameters.release.toFixed(1)} ms
{(parameters.release ?? 50).toFixed(1)} ms
</span>
</label>
<Slider
value={[Math.log10(parameters.release)]}
value={[Math.log10(parameters.release ?? 50)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, release: Math.pow(10, value) }))
}
@@ -470,11 +470,11 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Knee</span>
<span className="text-muted-foreground font-mono">
{(parameters as CompressorParameters | GateParameters).knee.toFixed(1)} dB
{((parameters as CompressorParameters | GateParameters).knee ?? 3).toFixed(1)} dB
</span>
</label>
<Slider
value={[(parameters as CompressorParameters | GateParameters).knee]}
value={[((parameters as CompressorParameters | GateParameters).knee ?? 3)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, knee: value }))
}
@@ -496,12 +496,12 @@ export function DynamicsParameterDialog({
<label className="text-sm font-medium text-foreground flex justify-between">
<span>Makeup Gain</span>
<span className="text-muted-foreground font-mono">
{(parameters as CompressorParameters | LimiterParameters).makeupGain > 0 ? '+' : ''}
{(parameters as CompressorParameters | LimiterParameters).makeupGain.toFixed(1)} dB
{((parameters as CompressorParameters | LimiterParameters).makeupGain ?? 0) > 0 ? '+' : ''}
{((parameters as CompressorParameters | LimiterParameters).makeupGain ?? 0).toFixed(1)} dB
</span>
</label>
<Slider
value={[(parameters as CompressorParameters | LimiterParameters).makeupGain]}
value={[((parameters as CompressorParameters | LimiterParameters).makeupGain ?? 0)]}
onValueChange={([value]) =>
setParameters((prev) => ({ ...prev, makeupGain: value }))
}