Fix skips not being counted and crash on old browser

This commit is contained in:
Ajay Ramachandran 2021-09-06 16:10:32 -04:00
parent 0d0171530c
commit 1f967b3f69

View file

@ -1059,7 +1059,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments:
const includedTimes: ScheduledTime[] = []; const includedTimes: ScheduledTime[] = [];
const startTimeIndexes: number[] = []; const startTimeIndexes: number[] = [];
const possibleTimes = sponsorTimes.flatMap((sponsorTime) => { const possibleTimes = sponsorTimes.map((sponsorTime) => {
const results = [{ const results = [{
...sponsorTime, ...sponsorTime,
scheduledTime: sponsorTime.segment[0] scheduledTime: sponsorTime.segment[0]
@ -1074,7 +1074,7 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments:
} }
return results; return results;
}) }).reduce((a, b) => a.concat(b), []);
for (let i = 0; i < possibleTimes.length; i++) { for (let i = 0; i < possibleTimes.length; i++) {
if ((minimum === undefined if ((minimum === undefined
@ -1112,7 +1112,7 @@ function sendTelemetryAndCount(skippingSegments: SponsorTime[], secondsSkipped:
let counted = false; let counted = false;
for (const segment of skippingSegments) { for (const segment of skippingSegments) {
const index = sponsorTimes.indexOf(segment); const index = sponsorTimes.findIndex((s) => s.segment === segment.segment);
if (index !== -1 && !sponsorSkipped[index]) { if (index !== -1 && !sponsorSkipped[index]) {
sponsorSkipped[index] = true; sponsorSkipped[index] = true;
if (!counted) { if (!counted) {