Count skips for chapters when viewed

This commit is contained in:
Ajay 2022-10-05 15:39:51 -04:00
parent 8cc3843ada
commit 03cd1b535b
2 changed files with 11 additions and 3 deletions

View file

@ -1577,7 +1577,9 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped:
sponsorSkipped[index] = true;
if (!counted) {
Config.config.minutesSaved = Config.config.minutesSaved + secondsSkipped / 60;
Config.config.skipCount = Config.config.skipCount + 1;
if (segment.actionType !== ActionType.Chapter) {
Config.config.skipCount = Config.config.skipCount + 1;
}
counted = true;
}
@ -2286,11 +2288,16 @@ function windowListenerHandler(event: MessageEvent): void {
}
function updateActiveSegment(currentTime: number): void {
previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime);
const activeSegments = previewBar?.updateChapterText(sponsorTimes, sponsorTimesSubmitting, currentTime);
chrome.runtime.sendMessage({
message: "time",
time: currentTime
});
const chapterSegments = activeSegments?.filter((segment) => segment.actionType === ActionType.Chapter);
if (chapterSegments?.length > 0) {
sendTelemetryAndCount(chapterSegments, 0, true);
}
}
function nextChapter(): void {

View file

@ -719,7 +719,7 @@ class PreviewBar {
}
}
updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): void {
updateChapterText(segments: SponsorTime[], submittingSegments: SponsorTime[], currentTime: number): SponsorTime[] {
if (!Config.config.showSegmentNameInChapterBar
|| ((!segments || segments.length <= 0) && submittingSegments?.length <= 0)) {
const chaptersContainer = this.getChaptersContainer();
@ -740,6 +740,7 @@ class PreviewBar {
});
this.setActiveSegments(activeSegments);
return activeSegments;
}
/**