Fixed preview sponsor times not turning into actual ones upon submission.

This commit is contained in:
Ajay Ramachandran
2020-02-08 23:16:44 -05:00
parent 50f293d783
commit 9026044528

View File

@@ -379,8 +379,20 @@ function sponsorsLookup(id: string, channelIDPromise?) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
sponsorDataFound = true; sponsorDataFound = true;
sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; let recievedSponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes;
UUIDs = JSON.parse(xmlhttp.responseText).UUIDs; let recievedUUIDs = JSON.parse(xmlhttp.responseText).UUIDs;
// Check if any old submissions should be kept
for (let i = 0; i < UUIDs.length; i++) {
if (UUIDs[i] === null) {
// This is a user submission, keep it
recievedSponsorTimes.push(sponsorTimes[i]);
recievedUUIDs.push(UUIDs[i]);
}
}
sponsorTimes = recievedSponsorTimes;
UUIDs = recievedUUIDs;
// Remove all submissions smaller than the minimum duration // Remove all submissions smaller than the minimum duration
if (Config.config.minDuration !== 0) { if (Config.config.minDuration !== 0) {
@@ -1091,10 +1103,12 @@ function sendSubmitMessage(){
Config.config.sponsorTimes.delete(currentVideoID); Config.config.sponsorTimes.delete(currentVideoID);
//add submissions to current sponsors list //add submissions to current sponsors list
if (sponsorTimes === null) sponsorTimes = [];
sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting); sponsorTimes = sponsorTimes.concat(sponsorTimesSubmitting);
for (let i = 0; i < sponsorTimesSubmitting.length; i++) { for (let i = 0; i < sponsorTimesSubmitting.length; i++) {
// Add some random IDs // Add placeholder IDs
UUIDs.push(utils.generateUserID()); UUIDs.push(null);
} }
// Empty the submitting times // Empty the submitting times