mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Don't regenerate groups if not needed
This commit is contained in:
@@ -62,6 +62,7 @@ class PreviewBar {
|
|||||||
originalChapterBar: HTMLElement;
|
originalChapterBar: HTMLElement;
|
||||||
originalChapterBarBlocks: NodeListOf<HTMLElement>;
|
originalChapterBarBlocks: NodeListOf<HTMLElement>;
|
||||||
chapterMargin: number;
|
chapterMargin: number;
|
||||||
|
lastRenderedSegments: PreviewBarSegment[];
|
||||||
unfilteredChapterGroups: ChapterGroup[];
|
unfilteredChapterGroups: ChapterGroup[];
|
||||||
chapterGroups: ChapterGroup[];
|
chapterGroups: ChapterGroup[];
|
||||||
|
|
||||||
@@ -308,6 +309,8 @@ class PreviewBar {
|
|||||||
this.container.appendChild(bar);
|
this.container.appendChild(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(this.segments)
|
||||||
|
console.trace()
|
||||||
this.createChaptersBar(this.segments.sort((a, b) => a.segment[0] - b.segment[0]));
|
this.createChaptersBar(this.segments.sort((a, b) => a.segment[0] - b.segment[0]));
|
||||||
|
|
||||||
if (chapterChevron) {
|
if (chapterChevron) {
|
||||||
@@ -356,8 +359,10 @@ class PreviewBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (segments !== this.lastRenderedSegments) {
|
||||||
// Merge overlapping chapters
|
// Merge overlapping chapters
|
||||||
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
||||||
|
}
|
||||||
|
|
||||||
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
||||||
|| (!Config.config.renderSegmentsAsChapters
|
|| (!Config.config.renderSegmentsAsChapters
|
||||||
@@ -368,6 +373,9 @@ class PreviewBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (segments !== this.lastRenderedSegments) {
|
||||||
|
this.lastRenderedSegments = segments;
|
||||||
|
|
||||||
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
|
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
|
||||||
if (filteredSegments) {
|
if (filteredSegments) {
|
||||||
let groups = this.unfilteredChapterGroups;
|
let groups = this.unfilteredChapterGroups;
|
||||||
@@ -387,6 +395,7 @@ class PreviewBar {
|
|||||||
} else {
|
} else {
|
||||||
this.chapterGroups = this.unfilteredChapterGroups;
|
this.chapterGroups = this.unfilteredChapterGroups;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.chapterGroups || this.chapterGroups.length <= 0) {
|
if (!this.chapterGroups || this.chapterGroups.length <= 0) {
|
||||||
if (this.customChaptersBar) this.customChaptersBar.style.display = "none";
|
if (this.customChaptersBar) this.customChaptersBar.style.display = "none";
|
||||||
|
|||||||
Reference in New Issue
Block a user