Fix fleet stale-status flicker during polling
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// Allow a polling cycle plus time for queued RCON requests and delivery.
|
||||
export const STATUS_REFRESH_MS = 30_000;
|
||||
export const ONLINE_MAX_MS = STATUS_REFRESH_MS + 15_000;
|
||||
// The UI clock ticks once per second and can trail a newly arrived report.
|
||||
const CLOCK_TOLERANCE_MS = 1_000;
|
||||
|
||||
export function freshStatusTimestamp(timestamp: string | null, now: number): boolean {
|
||||
const age = now - Date.parse(timestamp ?? '');
|
||||
return age >= -CLOCK_TOLERANCE_MS && age <= ONLINE_MAX_MS;
|
||||
}
|
||||
Reference in New Issue
Block a user