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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user