mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-18 05:28:32 +03:00
Fix chapters getting imported multiple times
This commit is contained in:
@@ -28,6 +28,7 @@ utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
|
|||||||
let sponsorDataFound = false;
|
let sponsorDataFound = false;
|
||||||
//the actual sponsorTimes if loaded and UUIDs associated with them
|
//the actual sponsorTimes if loaded and UUIDs associated with them
|
||||||
let sponsorTimes: SponsorTime[] = null;
|
let sponsorTimes: SponsorTime[] = null;
|
||||||
|
let existingChaptersImported = false;
|
||||||
//what video id are these sponsors for
|
//what video id are these sponsors for
|
||||||
let sponsorVideoID: VideoID = null;
|
let sponsorVideoID: VideoID = null;
|
||||||
// List of open skip notices
|
// List of open skip notices
|
||||||
@@ -246,8 +247,8 @@ function resetValues() {
|
|||||||
lastCheckTime = 0;
|
lastCheckTime = 0;
|
||||||
lastCheckVideoTime = -1;
|
lastCheckVideoTime = -1;
|
||||||
|
|
||||||
//reset sponsor times
|
|
||||||
sponsorTimes = null;
|
sponsorTimes = null;
|
||||||
|
existingChaptersImported = false;
|
||||||
sponsorSkipped = [];
|
sponsorSkipped = [];
|
||||||
|
|
||||||
videoInfo = null;
|
videoInfo = null;
|
||||||
@@ -763,6 +764,7 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||||||
|
|
||||||
const oldSegments = sponsorTimes || [];
|
const oldSegments = sponsorTimes || [];
|
||||||
sponsorTimes = recievedSegments;
|
sponsorTimes = recievedSegments;
|
||||||
|
existingChaptersImported = false;
|
||||||
|
|
||||||
// Hide all submissions smaller than the minimum duration
|
// Hide all submissions smaller than the minimum duration
|
||||||
if (Config.config.minDuration !== 0) {
|
if (Config.config.minDuration !== 0) {
|
||||||
@@ -811,8 +813,9 @@ async function sponsorsLookup(id: string, keepOldSubmissions = true) {
|
|||||||
if (Config.config.renderAsChapters) {
|
if (Config.config.renderAsChapters) {
|
||||||
GenericUtils.wait(() => getExistingChapters(sponsorVideoID, video.duration),
|
GenericUtils.wait(() => getExistingChapters(sponsorVideoID, video.duration),
|
||||||
5000, 100, (c) => c?.length > 0).then((chapters) => {
|
5000, 100, (c) => c?.length > 0).then((chapters) => {
|
||||||
if (chapters?.length > 0) {
|
if (!existingChaptersImported && chapters?.length > 0) {
|
||||||
sponsorTimes = sponsorTimes.concat(...chapters);
|
sponsorTimes = sponsorTimes.concat(...chapters);
|
||||||
|
existingChaptersImported = true;
|
||||||
updatePreviewBar();
|
updatePreviewBar();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user