From 16581d39a496d5ebd425778cb558cc6f4c56f557 Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 11 Dec 2022 16:24:53 -0500 Subject: [PATCH] Reverse fast interval to decimal It doesn't work when there are imported chapters closely or identical to existing chapters. Causes bar to extend too far. --- src/js-components/previewBar.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 626c0979..3d26cbdd 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -541,7 +541,7 @@ class PreviewBar { const nextSegment = segments[index + 1]; const nextTime = nextSegment ? nextSegment.segment[0] : this.videoDuration; const lastTime = result[result.length - 1]?.segment[1] || segment.segment[1]; - if (this.fastIntervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) { + if (this.intervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) { result.push({ segment: [lastTime, nextTime], originalDuration: 0, @@ -876,7 +876,7 @@ class PreviewBar { } private chapterGroupFilter(segment: SegmentContainer): boolean { - return segment.segment.length === 2 && this.fastIntervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE; + return segment.segment.length === 2 && this.intervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE; } intervalToPercentage(startTime: number, endTime: number) { @@ -887,10 +887,6 @@ class PreviewBar { return (this.timeToDecimal(endTime) - this.timeToDecimal(startTime)); } - fastIntervalToDecimal(startTime: number, endTime: number) { - return (this.fastTimeToDecimal(endTime) - this.fastTimeToDecimal(startTime)); - } - timeToPercentage(time: number): string { return `${this.timeToDecimal(time) * 100}%` } @@ -926,10 +922,6 @@ class PreviewBar { } } - return this.fastTimeToDecimal(time); - } - - fastTimeToDecimal(time: number): number { return Math.min(1, time / this.videoDuration); }