Преглед изворни кода

clear timer before starting new one

Aakansha Doshi пре 4 година
родитељ
комит
bc9c8f7ee2
1 измењених фајлова са 3 додато и 0 уклоњено
  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 networkSpeed = speed === "-1" ? "Error!" : speed;
     this.setState({ networkSpeed });
+    if (this.netStatsIntervalId) {
+      clearTimeout(this.netStatsIntervalId);
+    }
     this.netStatsIntervalId = setTimeout(
       this.calculateNetStats,
       NETWORK_SPEED_TIMEOUT_MS,