aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay <[email protected]>2022-09-14 03:18:41 -0400
committerAjay <[email protected]>2022-09-14 03:18:41 -0400
commit8054e3d8f29f12dfcc71de6b47dc9c57aa5f4f0f (patch)
tree67141e725872b5243d0b4d383b6d35fdbcbb3ebb
parentb0e1d5e7fa7b1ff100e72aa61581b7fe788686a2 (diff)
downloadSponsorBlock-8054e3d8f29f12dfcc71de6b47dc9c57aa5f4f0f.tar.gz
SponsorBlock-8054e3d8f29f12dfcc71de6b47dc9c57aa5f4f0f.zip
Fix chapters getting offset when small chapters filtered out
-rw-r--r--src/js-components/previewBar.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts
index a845b8f8..3b19910b 100644
--- a/src/js-components/previewBar.ts
+++ b/src/js-components/previewBar.ts
@@ -313,6 +313,12 @@ class PreviewBar {
// Merge overlapping chapters
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
const chaptersToRender = this.createChapterRenderGroups(filteredSegments).filter((segment) => this.chapterGroupFilter(segment));
+ // Fix missing sections due to filtered segments
+ for (let i = 1; i < chaptersToRender.length; i++) {
+ if (chaptersToRender[i].segment[0] !== chaptersToRender[i - 1].segment[1]) {
+ chaptersToRender[i - 1].segment[1] = chaptersToRender[i].segment[0]
+ }
+ }
if (chaptersToRender?.length <= 0) {
if (this.customChaptersBar) this.customChaptersBar.style.display = "none";