Copilot commented on code in PR #10900:
URL: https://github.com/apache/cloudstack/pull/10900#discussion_r2128348366
##########
ui/src/components/view/StatsTab.vue:
##########
@@ -371,6 +386,15 @@ export default {
return
}
this.fetchData()
+ },
+ refreshTime: function () {
+ this.fetchData()
+ if (this.refreshTime === '0') return
window.clearInterval(this.refreshIntervalId)
+
+ window.clearInterval(this.refreshIntervalId)
+ this.refreshIntervalId = window.setInterval(() => {
+ this.fetchData()
+ }, parseInt(this.refreshTime))
}
},
methods: {
Review Comment:
Computed properties should be pure and free of side effects; fetching data
and managing intervals belongs in a watcher or lifecycle hooks, not in a
computed.
```suggestion
this.setupRefreshInterval()
}
},
methods: {
setupRefreshInterval () {
window.clearInterval(this.refreshIntervalId)
if (this.refreshTime === '0') return
this.refreshIntervalId = window.setInterval(() => {
this.fetchData()
}, parseInt(this.refreshTime))
},
```
##########
ui/src/components/view/StatsTab.vue:
##########
@@ -371,6 +386,15 @@ export default {
return
}
this.fetchData()
+ },
+ refreshTime: function () {
+ this.fetchData()
+ if (this.refreshTime === '0') return
window.clearInterval(this.refreshIntervalId)
+
+ window.clearInterval(this.refreshIntervalId)
+ this.refreshIntervalId = window.setInterval(() => {
+ this.fetchData()
+ }, parseInt(this.refreshTime))
}
Review Comment:
Computed property 'refreshTime' conflicts with the data field named
'refreshTime', causing recursion and overriding the intended state. Replace
this computed block with a watcher on the data property or rename it to avoid
collision.
```suggestion
onRefreshTimeChange: function () {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]