-
Notifications
You must be signed in to change notification settings - Fork 4k
Fixed timer bug #11756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed timer bug #11756
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
lukasmasuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a timer bug by switching from an interval-based timer to one that computes elapsed time using the system clock. Key changes include:
- Adding a useRef hook to record the initial start time.
- Updating the timer calculation to rely on system time instead of incremental state updates.
- Enhancing tests in the Spinner component to verify the new timer behavior.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/lib/src/components/elements/Spinner/Spinner.tsx | Updated timer logic to compute elapsed time using Date.now() and useRef |
| frontend/lib/src/components/elements/Spinner/Spinner.test.tsx | Added tests using fake timers to verify timer updates based on system time |
Comments suppressed due to low confidence (1)
frontend/lib/src/components/elements/Spinner/Spinner.tsx:40
- [nitpick] Consider renaming 'startTimeRef' to 'initialTimeRef' to more clearly indicate that it stores the time when the component mounts.
const startTimeRef = useRef<number | null>(null)
Describe your changes
Fixes #11720 where on moving away from current window, the timer pauses. Now we use system time to compare and update timer accordingly instead of using set interval.
GitHub Issue Link (if applicable)
#11720
Testing Plan
Yes, done by me.
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.