Skip to content

Commit

Permalink
Fix time in move cut action
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Benz committed Apr 26, 2024
1 parent 04d81f3 commit 1b0825e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/redux/videoSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,28 +201,29 @@ const videoSlice = createSlice({
) => {
const leftSegmentIndex = action.payload.leftSegmentIndex;
const rightSegmentIndex = action.payload.leftSegmentIndex + 1;
const time = roundToDecimalPlace(action.payload.time, 0);

if (leftSegmentIndex < 0 || rightSegmentIndex >= state.segments.length) {
return;
}

// Merge overlapping left cut
if (action.payload.time <= state.segments[leftSegmentIndex].start) {
if (time <= state.segments[leftSegmentIndex].start) {
mergeSegments(state, rightSegmentIndex, leftSegmentIndex);
state.hasChanges = true;
return;
}

// Merge overlapping right cut
if (action.payload.time >= state.segments[rightSegmentIndex].end) {
if (time >= state.segments[rightSegmentIndex].end) {
mergeSegments(state, leftSegmentIndex, rightSegmentIndex);
state.hasChanges = true;
return;
}

// Move segment edges
state.segments[leftSegmentIndex].end = action.payload.time;
state.segments[rightSegmentIndex].start = action.payload.time;
state.segments[leftSegmentIndex].end = time;
state.segments[rightSegmentIndex].start = time;
state.hasChanges = true;
},
markAsDeletedOrAlive: state => {
Expand Down

0 comments on commit 1b0825e

Please sign in to comment.