forked from p34709852/monkey
UI crash due to multiple redundant telemetry requests fix
This commit is contained in:
parent
f941c9c5fc
commit
598872afee
|
@ -23,7 +23,8 @@ class MapPageComponent extends AuthComponent {
|
|||
telemetryLastTimestamp: null,
|
||||
isScrolledUp: false,
|
||||
telemetryLines: 0,
|
||||
telemetryCurrentLine: 0
|
||||
telemetryCurrentLine: 0,
|
||||
telemetryUpdateInProgress: false
|
||||
};
|
||||
this.telemConsole = React.createRef();
|
||||
this.handleScroll = this.handleScroll.bind(this);
|
||||
|
@ -72,16 +73,20 @@ class MapPageComponent extends AuthComponent {
|
|||
};
|
||||
|
||||
updateTelemetryFromServer = () => {
|
||||
if( this.state.telemetryUpdateInProgress ) {
|
||||
return
|
||||
}
|
||||
this.setState({telemetryUpdateInProgress: true});
|
||||
this.authFetch('/api/telemetry-feed?timestamp=' + this.state.telemetryLastTimestamp)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if ('telemetries' in res) {
|
||||
let newTelem = this.state.telemetry.concat(res['telemetries']);
|
||||
|
||||
this.setState(
|
||||
{
|
||||
telemetry: newTelem,
|
||||
telemetryLastTimestamp: res['timestamp']
|
||||
telemetryLastTimestamp: res['timestamp'],
|
||||
telemetryUpdateInProgress: false
|
||||
});
|
||||
this.props.onStatusChange();
|
||||
|
||||
|
|
Loading…
Reference in New Issue