Skip to content

Commit 2f02b36

Browse files
committed
fix: handle empty segment array in TimelineSegments props update (#331)
The propSegments useEffect guard used propSegments.length > 0 which blocked the props-based update path when all recordings were deleted (empty array case). While the timelineState subscription compensated for this via its own update path, the guard was semantically incorrect. Replace the length guard with Array.isArray() so that any valid array (including an empty one after all recordings are deleted) correctly updates the component's local segment state via both the props path and the subscription path.
1 parent ce89bfc commit 2f02b36

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

web/js/components/preact/timeline/TimelineSegments.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export function TimelineSegments({ segments: propSegments }) {
2121
const [endHour, setEndHour] = useState(24);
2222
const currentSegmentIndexRef = useRef(-1);
2323

24-
// Update segments when props change
24+
// Update segments when props change (including when cleared to empty on deletion)
2525
useEffect(() => {
26-
if (propSegments && propSegments.length > 0) {
26+
if (Array.isArray(propSegments)) {
2727
setSegments(propSegments);
2828
}
2929
}, [propSegments]);

0 commit comments

Comments
 (0)