fix a bug with clear segments

pull/1474/head
Mikael Finstad 3 years ago
parent a22dcdc92c
commit 5347dbdff0
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -638,7 +638,7 @@ const App = memo(() => {
setCanvasPlayerEventId(0);
setDuration();
cutSegmentsHistory.go(0);
clearSegments(); // TODO this will cause two history items
clearSegments();
setCutStartTimeManual();
setCutEndTimeManual();
setFileFormat();

@ -142,16 +142,20 @@ export default ({
}, [currentApparentCutSeg.end, currentApparentCutSeg.start, filePath, loadCutSegments, mainVideoStream]);
const removeSegments = useCallback((removeSegmentIds) => {
if (cutSegments.length === 1 && cutSegments[0].start == null && cutSegments[0].end == null) return; // We are at initial segment, nothing more we can do (it cannot be removed)
setCutSegments((existing) => {
const newSegments = existing.filter((seg) => !removeSegmentIds.includes(seg.segId));
setCutSegments((existingSegments) => {
if (existingSegments.length === 1 && existingSegments[0].start == null && existingSegments[0].end == null) {
return existingSegments; // We are at initial segment, nothing more we can do (it cannot be removed)
}
const newSegments = existingSegments.filter((seg) => !removeSegmentIds.includes(seg.segId));
if (newSegments.length === 0) {
clearSegments(); // when removing the last segments, we start over
return existing;
// when removing the last segments, we start over
clearSegCounter();
return createInitialCutSegments();
}
return newSegments;
});
}, [clearSegments, cutSegments, setCutSegments]);
}, [clearSegCounter, createInitialCutSegments, setCutSegments]);
const removeCutSegment = useCallback((index) => {
removeSegments([cutSegments[index].segId]);

Loading…
Cancel
Save