mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 14:37:23 +03:00
Fix filtered chapter group generation
This commit is contained in:
@@ -313,19 +313,6 @@ class PreviewBar {
|
|||||||
|
|
||||||
// Merge overlapping chapters
|
// Merge overlapping chapters
|
||||||
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
||||||
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
|
|
||||||
if (filteredSegments && filteredSegments.length !== segments.length) {
|
|
||||||
this.chapterGroups = this.createChapterRenderGroups(filteredSegments).filter((segment) => this.chapterGroupFilter(segment));
|
|
||||||
|
|
||||||
// Fix missing sections due to filtered segments
|
|
||||||
for (let i = 1; i < this.chapterGroups.length; i++) {
|
|
||||||
if (this.chapterGroups[i].segment[0] !== this.chapterGroups[i - 1].segment[1]) {
|
|
||||||
this.chapterGroups[i - 1].segment[1] = this.chapterGroups[i].segment[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.chapterGroups = this.unfilteredChapterGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
||||||
|| (!Config.config.renderSegmentsAsChapters
|
|| (!Config.config.renderSegmentsAsChapters
|
||||||
@@ -337,6 +324,26 @@ class PreviewBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
|
||||||
|
if (filteredSegments) {
|
||||||
|
let groups = this.unfilteredChapterGroups;
|
||||||
|
if (filteredSegments.length !== segments.length) {
|
||||||
|
groups = this.createChapterRenderGroups(filteredSegments);
|
||||||
|
}
|
||||||
|
this.chapterGroups = groups.filter((segment) => this.chapterGroupFilter(segment));
|
||||||
|
|
||||||
|
if (groups.length !== this.chapterGroups.length) {
|
||||||
|
// Fix missing sections due to filtered segments
|
||||||
|
for (let i = 1; i < this.chapterGroups.length; i++) {
|
||||||
|
if (this.chapterGroups[i].segment[0] !== this.chapterGroups[i - 1].segment[1]) {
|
||||||
|
this.chapterGroups[i - 1].segment[1] = this.chapterGroups[i].segment[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.chapterGroups = this.unfilteredChapterGroups;
|
||||||
|
}
|
||||||
|
|
||||||
// Create it from cloning
|
// Create it from cloning
|
||||||
let createFromScratch = false;
|
let createFromScratch = false;
|
||||||
if (!this.customChaptersBar || !this.progressBar.contains(this.customChaptersBar)) {
|
if (!this.customChaptersBar || !this.progressBar.contains(this.customChaptersBar)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user