Automattic / Automattic/jetpack
Milestone widget: Countdown is not smooth and will skip seconds
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
#### Steps to reproduce the issue
1. Add a Milestone sidebar widget
2. Set the milestone to happen in the next minute
3. Visit website and look the countdown
4. Note that it will eventually skip a number. For example, go from 19 to 17.
#### What I expected
The countdown should go through all numbers
### How to fix
Today, when there is less than 1 minute to reach the Milestone, the widget makes one request per second, and the ajax response returns how many seconds are left together with the instructions to ask again in one second.
What can happen is that the ajax call might not happen exactly 60 seconds after the previous call, because the script has to wait for the server to respond. So very often we have one second skipped.
What we could do is, whenever we are under 60 seconds to reach the milestone, we would return only the message and the number of seconds to the milestone in the `response.refresh` attribute.
Then we would leave the countdown entirely for the JS, and make another request only when we reach zero.
Contributor guide
Assessment
This issue has not been assessed yet.