From 3603e87567a797b34c4fb41ec3a655a84fdbef9f Mon Sep 17 00:00:00 2001
From: Shivam Gupta <231542@kit.ac.in>
Date: Mon, 15 Jun 2026 11:01:27 +0530
Subject: [PATCH 1/2] fix: pause leaderboard polling when tab is hidden using
Page Visibility API
---
frontend/leaderboard.html | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/frontend/leaderboard.html b/frontend/leaderboard.html
index 932e40f6..7e11f5f9 100644
--- a/frontend/leaderboard.html
+++ b/frontend/leaderboard.html
@@ -187,7 +187,27 @@
Leaderboard
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 = {};
From 9a135f34fca77d10c61b014ddeff46c0905a6c77 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Mon, 15 Jun 2026 15:08:03 +0000
Subject: [PATCH 2/2] style: auto-format code with Prettier (/format)
---
frontend/leaderboard.html | 42 +++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/frontend/leaderboard.html b/frontend/leaderboard.html
index 7e11f5f9..977b9ca7 100644
--- a/frontend/leaderboard.html
+++ b/frontend/leaderboard.html
@@ -187,27 +187,27 @@ Leaderboard
setupPaginationListeners();
fetchLeaderboardData();
// Poll every 2 minutes to detect new syncs
- // 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();
+ // 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 = {};