Browse Source

clear timer before starting new one

Aakansha Doshi 4 years ago
parent
commit
bc9c8f7ee2
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/components/App.tsx

+ 3 - 0
src/components/App.tsx

@@ -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,