mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
fix: Initialize lastPollTime on first RAF callback
Co-authored-by: jhbruhn <1036566+jhbruhn@users.noreply.github.com>
This commit is contained in:
parent
03e083b4a3
commit
cca86ff53e
1 changed files with 5 additions and 0 deletions
|
|
@ -382,6 +382,11 @@ export const useMachineStore = create<MachineState>((set, get) => ({
|
||||||
// - Smoother animations and UI updates
|
// - Smoother animations and UI updates
|
||||||
// - More efficient rendering
|
// - More efficient rendering
|
||||||
const poll = async (timestamp: number) => {
|
const poll = async (timestamp: number) => {
|
||||||
|
// Initialize lastPollTime on first call
|
||||||
|
if (lastPollTime === 0) {
|
||||||
|
lastPollTime = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if enough time has passed since last poll
|
// Check if enough time has passed since last poll
|
||||||
const interval = getPollInterval();
|
const interval = getPollInterval();
|
||||||
const elapsed = timestamp - lastPollTime;
|
const elapsed = timestamp - lastPollTime;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue