jedi-gg / swgoh.gg.public

SWGOH.GG Issues
https://swgoh.gg
41 stars 12 forks source link

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

Open dkeeslin opened 1 year ago

dkeeslin commented 1 year ago

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   | };