Skip to content

Conversation

@totomagarinos
Copy link

Problem

The study session timer relied on incrementing sessionTime every second using setInterval.
When the tab is inactive, the timer would freeze because browsers throttle background intervals.

Solution

  • Store the session start timestamp (startTime) when starting or resuming the session.
  • Calculate elapsed time using Date.now() - startTime instead of incrementing by 1 each second.
  • Ensures the timer always reflects real elapsed time, even if the tab is inactive.

Testing

  • Started a session, left the tab inactive for several minutes, returned, and verified the timer reflects the correct elapsed time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant