fix: Chapters: If adding a chapter between two existing chapters, the order of the chapters are wrong in the editor timeline, and in the player chapter view

This commit is contained in:
Yiannis Christodoulou 2025-10-13 01:40:03 +03:00
parent f67021b17b
commit e06115b8ee

View File

@ -1878,7 +1878,9 @@ const TimelineControls = ({
// Render the clip segments on the timeline // Render the clip segments on the timeline
const renderClipSegments = () => { const renderClipSegments = () => {
return clipSegments.map((segment, index) => { // Sort segments by start time to ensure correct chronological order
const sortedSegments = [...clipSegments].sort((a, b) => a.startTime - b.startTime);
return sortedSegments.map((segment, index) => {
const startPercent = (segment.startTime / duration) * 100; const startPercent = (segment.startTime / duration) * 100;
const widthPercent = ((segment.endTime - segment.startTime) / duration) * 100; const widthPercent = ((segment.endTime - segment.startTime) / duration) * 100;