From 6a3402d5351429776ec9614f979a56e33efbc962 Mon Sep 17 00:00:00 2001 From: Martin Man Date: Tue, 22 Oct 2024 18:08:27 +0200 Subject: [PATCH] fix: Prevent NaN (division by zero) on Dashboard --- src/client/views/dashboard/Dashboard.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/views/dashboard/Dashboard.tsx b/src/client/views/dashboard/Dashboard.tsx index 7432d23..f0b7093 100644 --- a/src/client/views/dashboard/Dashboard.tsx +++ b/src/client/views/dashboard/Dashboard.tsx @@ -37,6 +37,7 @@ function Dashboard() { }) const deviceKeys = Object.keys(deviceStatistics || {}).sort() + const adjustedMeasurementRate = measurementRate !== 0 ? measurementRate : 0.001 const websocketStatus = useSelector((state: AppState) => state.websocketStatus) if (websocketStatus !== "open") { @@ -102,7 +103,7 @@ function Dashboard() { {deviceStats.measurementRate} ( - {((deviceStats.measurementRate / measurementRate) * 100).toFixed(0)} + {((deviceStats.measurementRate / adjustedMeasurementRate) * 100).toFixed(0)} %) @@ -111,7 +112,7 @@ function Dashboard() {