Show both chapter names when small chapter in big chapter

This commit is contained in:
Ajay
2022-04-21 14:54:57 -04:00
parent 6325d3539c
commit 9f02bf4ce2

View File

@@ -125,21 +125,25 @@ class PreviewBar {
const [normalSegments, chapterSegments] = const [normalSegments, chapterSegments] =
partition(this.segments.filter((s) => s.source !== SponsorSourceType.YouTube), partition(this.segments.filter((s) => s.source !== SponsorSourceType.YouTube),
(segment) => segment.actionType !== ActionType.Chapter); (segment) => segment.actionType !== ActionType.Chapter);
const normalSegment = this.getSmallestSegment(timeInSeconds, normalSegments); let mainSegment = this.getSmallestSegment(timeInSeconds, normalSegments);
const chapterSegment = this.getSmallestSegment(timeInSeconds, chapterSegments); let secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments);
if (mainSegment === null && secondarySegment !== null) {
mainSegment = secondarySegment;
secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments.filter((s) => s !== secondarySegment));
}
if (normalSegment === null && chapterSegment === null) { if (mainSegment === null && secondarySegment === null) {
this.categoryTooltipContainer.classList.remove(TOOLTIP_VISIBLE_CLASS); this.categoryTooltipContainer.classList.remove(TOOLTIP_VISIBLE_CLASS);
} else { } else {
this.categoryTooltipContainer.classList.add(TOOLTIP_VISIBLE_CLASS); this.categoryTooltipContainer.classList.add(TOOLTIP_VISIBLE_CLASS);
if (normalSegment !== null && chapterSegment !== null) { if (mainSegment !== null && secondarySegment !== null) {
this.categoryTooltipContainer.classList.add("sponsorTwoTooltips"); this.categoryTooltipContainer.classList.add("sponsorTwoTooltips");
} else { } else {
this.categoryTooltipContainer.classList.remove("sponsorTwoTooltips"); this.categoryTooltipContainer.classList.remove("sponsorTwoTooltips");
} }
this.setTooltipTitle(normalSegment, this.categoryTooltip); this.setTooltipTitle(mainSegment, this.categoryTooltip);
this.setTooltipTitle(chapterSegment, this.chapterTooltip); this.setTooltipTitle(secondarySegment, this.chapterTooltip);
// Used to prevent overlapping // Used to prevent overlapping
this.categoryTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters); this.categoryTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters);