Skip to content

Commit 32427d9

Browse files
committed
refactor(studio): guard the diamond connector's previous keyframe
CONTRIBUTING.md asks for a guard clause rather than a non-null assertion outside an already-checked path. The index check and the lookup are now the same guard.
1 parent 2c3ed8f commit 32427d9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/studio/src/player/components/TimelineClipDiamonds.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ export const TimelineDiamondLane = memo(function TimelineDiamondLane({
239239
}}
240240
>
241241
{sorted.map((kf, i) => {
242-
if (i === 0) return null;
243-
const prev = sorted[i - 1]!;
242+
const prev = sorted[i - 1];
243+
if (!prev) return null;
244244
const x1 = Math.max(0, Math.min(clipWidthPx, (prev.percentage / 100) * clipWidthPx));
245245
const x2 = Math.max(0, Math.min(clipWidthPx, (kf.percentage / 100) * clipWidthPx));
246246
if (x2 - x1 < 1) return null;

0 commit comments

Comments
 (0)