Implement dynamic lobby polling with faster refresh rate and prevent concurrent requests

Added faster polling interval (700ms) for pre-game lobby to show joining players in near real-time, while keeping slower 2.5s refresh for active games. Implemented pending request flag to prevent concurrent API calls from overlapping. Added `cache: "no-store"` to fetch configuration to ensure fresh data on every request. Updated useEffect dependency array to re-initialize polling when game start state changes.
This commit is contained in:
2026-08-02 09:22:48 +02:00
parent 1bbbe31500
commit 29e063d88d
2 changed files with 11 additions and 5 deletions
+2 -1
View File
@@ -3,9 +3,10 @@ import { API_BASE } from "../constants";
export async function api(path, opts = {}) {
const res = await fetch(API_BASE + path, {
credentials: "include",
cache: "no-store",
headers: { "Content-Type": "application/json" },
...opts,
});
if (!res.ok) throw new Error(await res.text());
return res.json();
}
}