Fix draft timer display drifting due to server-client clock skew #74
1 changed files with 1 additions and 1 deletions
|
|
@ -508,7 +508,7 @@ export default function DraftRoom() {
|
||||||
// loaderTimerNow is server-side Date.now() — subtract from server expiresAt to get ms remaining
|
// loaderTimerNow is server-side Date.now() — subtract from server expiresAt to get ms remaining
|
||||||
// without skew, then re-anchor to client clock.
|
// without skew, then re-anchor to client clock.
|
||||||
const active = timers.find((t) => t.picksExpiresAt && t.picksExpiresAt.getTime() > loaderTimerNow);
|
const active = timers.find((t) => t.picksExpiresAt && t.picksExpiresAt.getTime() > loaderTimerNow);
|
||||||
if (!active) return null;
|
if (!active?.picksExpiresAt) return null;
|
||||||
const secondsRemaining = Math.ceil((active.picksExpiresAt.getTime() - loaderTimerNow) / 1000);
|
const secondsRemaining = Math.ceil((active.picksExpiresAt.getTime() - loaderTimerNow) / 1000);
|
||||||
return { teamId: active.teamId, expiresAt: Date.now() + secondsRemaining * 1000 };
|
return { teamId: active.teamId, expiresAt: Date.now() + secondsRemaining * 1000 };
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue