mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Don't run some chapter init code when not necessary
This commit is contained in:
parent
7eb6b3a79d
commit
3b776991a6
1 changed files with 8 additions and 7 deletions
|
@ -309,8 +309,6 @@ class PreviewBar {
|
|||
this.container.appendChild(bar);
|
||||
}
|
||||
|
||||
console.log(this.segments)
|
||||
console.trace()
|
||||
this.createChaptersBar(this.segments.sort((a, b) => a.segment[0] - b.segment[0]));
|
||||
|
||||
if (chapterChevron) {
|
||||
|
@ -359,7 +357,10 @@ class PreviewBar {
|
|||
return;
|
||||
}
|
||||
|
||||
if (segments !== this.lastRenderedSegments) {
|
||||
const remakingBar = segments !== this.lastRenderedSegments;
|
||||
if (remakingBar) {
|
||||
this.lastRenderedSegments = segments;
|
||||
|
||||
// Merge overlapping chapters
|
||||
this.unfilteredChapterGroups = this.createChapterRenderGroups(segments);
|
||||
}
|
||||
|
@ -373,9 +374,7 @@ class PreviewBar {
|
|||
return;
|
||||
}
|
||||
|
||||
if (segments !== this.lastRenderedSegments) {
|
||||
this.lastRenderedSegments = segments;
|
||||
|
||||
if (remakingBar) {
|
||||
const filteredSegments = segments?.filter((segment) => this.chapterFilter(segment));
|
||||
if (filteredSegments) {
|
||||
let groups = this.unfilteredChapterGroups;
|
||||
|
@ -453,7 +452,9 @@ class PreviewBar {
|
|||
}
|
||||
}
|
||||
|
||||
this.updateChapterAllMutation(this.originalChapterBar, this.progressBar, true);
|
||||
if (remakingBar) {
|
||||
this.updateChapterAllMutation(this.originalChapterBar, this.progressBar, true);
|
||||
}
|
||||
}
|
||||
|
||||
createChapterRenderGroups(segments: PreviewBarSegment[]): ChapterGroup[] {
|
||||
|
|
Loading…
Reference in a new issue