mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 20:47:11 +03:00
Don't run some chapter init code when not necessary
This commit is contained in:
@@ -309,8 +309,6 @@ 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) {
|
||||||
@@ -359,7 +357,10 @@ class PreviewBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segments !== this.lastRenderedSegments) {
|
const remakingBar = segments !== this.lastRenderedSegments;
|
||||||
|
if (remakingBar) {
|
||||||
|
this.lastRenderedSegments = segments;
|
||||||
|
|
||||||
// Merge overlapping chapters
|
// Merge overlapping chapters
|
||||||
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
||||||
}
|
}
|
||||||
@@ -373,9 +374,7 @@ class PreviewBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segments !== this.lastRenderedSegments) {
|
if (remakingBar) {
|
||||||
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;
|
||||||
@@ -453,8 +452,10 @@ class PreviewBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remakingBar) {
|
||||||
this.updateChapterAllMutation(this.originalChapterBar, this.progressBar, true);
|
this.updateChapterAllMutation(this.originalChapterBar, this.progressBar, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
createChapterRenderGroups(segments: PreviewBarSegment[]): ChapterGroup[] {
|
createChapterRenderGroups(segments: PreviewBarSegment[]): ChapterGroup[] {
|
||||||
const result: ChapterGroup[] = [];
|
const result: ChapterGroup[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user