diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html index dff76ea..f8b85a9 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html @@ -266,8 +266,9 @@ const pageCount = data.pageCount(); const elapsed = Date.now() - startTime; + // Skip tournaments with no pages (this shouldn't happen now, but just in case) if (pageCount === 0) { - console.log('No pages to display yet'); + console.log('Tournament has no content, should have been filtered out'); return; } @@ -289,10 +290,12 @@ reason = 'Single page - 15 seconds elapsed'; } } else if (pageCount > 1) { - // Multi-page tournament: complete when we cycle back to page 1 after seeing all pages - if (currentActive === 1 && lastActive > 1 && maxPagesSeen >= pageCount) { + // Multi-page tournament: complete when we're about to go back to page 1 after seeing all pages + // Check if we're at the last page and have seen all pages + if (currentActive === pageCount && maxPagesSeen >= pageCount && lastActive !== null) { + // We're at the last page and have seen all pages - complete now before going back to page 1 shouldComplete = true; - reason = 'Multi-page - full cycle completed'; + reason = 'Multi-page - completed at last page (avoiding first page repeat)'; } else if (elapsed >= completionTime) { // Fallback: complete after (pageCount * 15 seconds) shouldComplete = true;