web: prevent status update loop in background
When leaving the status page while it is waiting for status data, the callback happens when the status page is not mounted, resulting in the update loop timer not being cleared. This change prevents that by setting the visible attribute to false when leaving the page, so that the update is not scheduled when the page is not visible. Change-Id: I9f3db68bb77c52d0f477b8322bbf52bd3cc81fe1
This commit is contained in:
parent
6d6c69f93e
commit
00f4de3c51
|
@ -84,7 +84,7 @@ class StatusPage extends Refreshable {
|
|||
updateData = (force) => {
|
||||
if (force || (this.visible && this.state.autoReload)) {
|
||||
this.props.dispatch(fetchStatusIfNeeded(this.props.tenant))
|
||||
.then(() => {if (this.state.autoReload) {
|
||||
.then(() => {if (this.state.autoReload && this.visible) {
|
||||
this.timer = setTimeout(this.updateData, 5000)
|
||||
}})
|
||||
}
|
||||
|
@ -106,6 +106,7 @@ class StatusPage extends Refreshable {
|
|||
clearTimeout(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
this.visible = false
|
||||
document.removeEventListener(
|
||||
this.visibilityChangeEvent, this.visibilityListener)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue