Fix race condition causing double fetch

This commit is contained in:
Ajay
2022-11-23 23:37:52 -05:00
parent 8b6fb98b3d
commit 8d0a4ec2e6

View File

@@ -154,6 +154,7 @@ let isAdPlaying = false;
let lastResponseStatus: number; let lastResponseStatus: number;
let retryCount = 0; let retryCount = 0;
let lookupWaiting = false;
// Contains all of the functions and variables needed by the skip notice // Contains all of the functions and variables needed by the skip notice
const skipNoticeContentContainer: ContentContainer = () => ({ const skipNoticeContentContainer: ContentContainer = () => ({
@@ -965,10 +966,15 @@ function setupCategoryPill() {
} }
async function sponsorsLookup(keepOldSubmissions = true) { async function sponsorsLookup(keepOldSubmissions = true) {
if (lookupWaiting) return;
if (!video || !isVisible(video)) refreshVideoAttachments(); if (!video || !isVisible(video)) refreshVideoAttachments();
//there is still no video here //there is still no video here
if (!video) { if (!video) {
setTimeout(() => sponsorsLookup(), 100); lookupWaiting = true;
setTimeout(() => {
lookupWaiting = false;
sponsorsLookup()
}, 100);
return; return;
} }