Skip to content

Commit

Permalink
Fix incorrect state inheritance during merges
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Benz committed Sep 4, 2023
1 parent 212ab47 commit f34f771
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,15 @@ const mergeSegments = (state: video, startSegmentIndex: number, endSegmentIndex:
return
}

const minSegmentIndex = Math.min(startSegmentIndex, endSegmentIndex)

// Increase activeSegment length
state.segments[minSegmentIndex].start = Math.min(
state.segments[startSegmentIndex].start = Math.min(
state.segments[startSegmentIndex].start, state.segments[endSegmentIndex].start)
state.segments[minSegmentIndex].end = Math.max(
state.segments[startSegmentIndex].end = Math.max(
state.segments[startSegmentIndex].end, state.segments[endSegmentIndex].end)

// Remove the last segment and segments between
// Remove the end segment and segments between
state.segments.splice(
minSegmentIndex + 1,
startSegmentIndex < endSegmentIndex ? startSegmentIndex + 1 : endSegmentIndex,
Math.abs(endSegmentIndex - startSegmentIndex)
);

Expand Down

0 comments on commit f34f771

Please sign in to comment.