clear timer before starting new one

This commit is contained in:
Aakansha Doshi 2021-02-07 17:36:27 +05:30
parent 3eacd6f07b
commit bc9c8f7ee2

View File

@ -1034,6 +1034,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const speed = await getNetworkSpeed(); const speed = await getNetworkSpeed();
const networkSpeed = speed === "-1" ? "Error!" : speed; const networkSpeed = speed === "-1" ? "Error!" : speed;
this.setState({ networkSpeed }); this.setState({ networkSpeed });
if (this.netStatsIntervalId) {
clearTimeout(this.netStatsIntervalId);
}
this.netStatsIntervalId = setTimeout( this.netStatsIntervalId = setTimeout(
this.calculateNetStats, this.calculateNetStats,
NETWORK_SPEED_TIMEOUT_MS, NETWORK_SPEED_TIMEOUT_MS,