Skip to content

Commit

Permalink
clearTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash committed Oct 29, 2024
1 parent 3684fa1 commit f35d52e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/src/js/components/latest-levels-auto-refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class LatestLevelsAutoRefresh {
constructor (targetMinutes = [4, 19, 34, 49]) {
this.timeout = null
this.timeAgoInterval = null
this.timeAgoTimeout = null
this.liveStatusMessages = []
this.targetMinutes = targetMinutes

Expand Down Expand Up @@ -31,7 +32,7 @@ class LatestLevelsAutoRefresh {
updateTimeAgo = () => {
console.log('--updateTimeAgo() started')

setTimeout(() => {
this.timeAgoTimeout = setTimeout(() => {
this.renderTimeAgo()
this.timeAgoInterval = setInterval(this.renderTimeAgo, 60000)
}, (60 - new Date().getSeconds()) * 1000)
Expand Down Expand Up @@ -137,7 +138,9 @@ class LatestLevelsAutoRefresh {
if (fetchedValue?.textContent !== currentValue?.textContent) {
console.log('--new value fetched')
clearInterval(this.timeAgoInterval)
clearTimeout(this.timeAgoTimeout)
console.log('--interval cleared')
console.log('--timeout cleared')

currentValue.textContent = fetchedValue.textContent

Expand Down

0 comments on commit f35d52e

Please sign in to comment.