swgoh.gg.public icon indicating copy to clipboard operation
swgoh.gg.public copied to clipboard

Time left for refresh not counting down correctly when there's less than an hour to go

Open dkeeslin opened this issue 1 year ago • 0 comments

I noticed that the "sync" update button will count down from 60 seconds repeatedly whenever there is less than an hour to go in the countdown. In looking at the page source I found the code below:

this.updateButtonCountdown =function() {

  | let display;   | if(this.getHoursRemaining() > 0){   | display = this.getHoursRemaining() + ' Hours';   | }   | else if (this.getSecondsRemaining() <= 60) {   | display = this.getSecondsRemaining() + ' Seconds';   | } else {   | display = this.getMinutesRemaining() + ' Minutes';   | }   | this.syncButton.value = display   | };

The logic is set up incorrectly because this.getSecondsRemaining() <= 60 will return True regardless of the number of minutes remaining, so you will always show a 59 second countdown repeatedly. a possible alternative that I would suggest is:

this.updateButtonCountdown =function() {

  | let display;   | if(this.getHoursRemaining() > 0){   | display = this.getHoursRemaining() + ' Hours'; #Current state. Seems to work correctly   | } | else if (this.getMinutesRemaining > 0){ # Use the same logic as above for the hours | display = this.getMinutesRemaining() + 'Minutes'; | } else { | display = this.getSecondsRemaining() + 'Seconds'; # Only show the seconds countdown if there are no minutes left | }   | this.syncButton.value = display   | };

dkeeslin avatar Apr 15 '23 04:04 dkeeslin