Don't load segments from url multiple times

This commit is contained in:
Ajay
2022-02-06 13:13:08 -05:00
parent e8307a2af7
commit 2575141d35

View File

@@ -98,6 +98,7 @@ addHotkeyListener();
/** Segments created by the user which have not yet been submitted. */
let sponsorTimesSubmitting: SponsorTime[] = [];
let loadedPreloadedSegment = false;
//becomes true when isInfoFound is called
//this is used to close the popup on YouTube when the other popup opens
@@ -2023,8 +2024,12 @@ function showTimeWithoutSkips(skippedDuration: number): void {
}
function checkForPreloadedSegment() {
if (loadedPreloadedSegment) return;
loadedPreloadedSegment = true;
const hashParams = getHashParams();
let pushed = false;
const segments = hashParams.segments;
if (Array.isArray(segments)) {
for (const segment of segments) {
@@ -2037,8 +2042,14 @@ function checkForPreloadedSegment() {
actionType: segment.actionType ? segment.actionType : ActionType.Skip,
source: SponsorSourceType.Local
});
pushed = true;
}
}
}
}
if (pushed) {
Config.config.segmentTimes.set(sponsorVideoID, sponsorTimesSubmitting);
}
}