From 1f967b3f694d5584f73de40fe9bdab991bc766a8 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Mon, 6 Sep 2021 16:10:32 -0400 Subject: [PATCH] Fix skips not being counted and crash on old browser --- src/content.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index a4175d61..5efec029 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1059,7 +1059,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments: const includedTimes: ScheduledTime[] = []; const startTimeIndexes: number[] = []; - const possibleTimes = sponsorTimes.flatMap((sponsorTime) => { + const possibleTimes = sponsorTimes.map((sponsorTime) => { const results = [{ ...sponsorTime, scheduledTime: sponsorTime.segment[0] @@ -1074,7 +1074,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments: } return results; - }) + }).reduce((a, b) => a.concat(b), []); for (let i = 0; i < possibleTimes.length; i++) { if ((minimum === undefined @@ -1112,7 +1112,7 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped: let counted = false; for (const segment of skippingSegments) { - const index = sponsorTimes.indexOf(segment); + const index = sponsorTimes.findIndex((s) => s.segment === segment.segment); if (index !== -1 && !sponsorSkipped[index]) { sponsorSkipped[index] = true; if (!counted) {