Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion frontend/leaderboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,27 @@ <h1 class="page-title">Leaderboard</h1>
setupPaginationListeners();
fetchLeaderboardData();
// Poll every 2 minutes to detect new syncs
setInterval(fetchLeaderboardData, 2 * 60 * 1000);
// Page Visibility API — pause polling when tab is hidden
let pollInterval;

function startPolling() {
pollInterval = setInterval(fetchLeaderboardData, 2 * 60 * 1000);
}

function stopPolling() {
clearInterval(pollInterval);
}

document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
fetchLeaderboardData(); // immediate refresh when tab becomes visible
startPolling();
} else {
stopPolling();
}
});

startPolling();
});

const leaderboardData = {};
Expand Down
Loading