Do only one status request at a time

Currently we wait 5 seconds from the start of the request to do the
next request. On openstack the request can take more than 5 seconds so
we end up doing more requests in parallel. To fix this we should set
the timer for the next request when receiving the response data.

Change-Id: I543149f7f82cdd208cc50c30d1e29ea9a4cd453a
This commit is contained in:
Tobias Henkel 2018-10-11 18:09:22 +02:00
parent 2200816ad5
commit 1aba9d1d5d
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
1 changed files with 6 additions and 3 deletions

View File

@ -98,8 +98,14 @@ class StatusPage extends React.Component {
// .then(sleeper(2000))
.then(response => {
this.setState({status: response.data, loading: false})
if (this.state.autoReload) {
this.timer = setTimeout(this.updateData, 5000)
}
}).catch(error => {
this.setState({error: error.message, status: null})
if (this.state.autoReload) {
this.timer = setTimeout(this.updateData, 5000)
}
})
}
// Clear any running timer
@ -107,9 +113,6 @@ class StatusPage extends React.Component {
clearTimeout(this.timer)
this.timer = null
}
if (this.state.autoReload) {
this.timer = setTimeout(this.updateData, 5000)
}
}
componentDidMount () {