From dc8d216e60975ad12ac1d0624ff29a47e64935a3 Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Sun, 30 Jun 2024 18:59:43 -0400 Subject: [PATCH] fix: UI update after mock sensor change [PT-187809478] Updates the mock sensor poll value to use measurement and unit based on sensor selected. --- src/mobile-app/components/sensor.tsx | 4 ++-- src/sensors/mock-sensor.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mobile-app/components/sensor.tsx b/src/mobile-app/components/sensor.tsx index fe010b9..4b8aec1 100644 --- a/src/mobile-app/components/sensor.tsx +++ b/src/mobile-app/components/sensor.tsx @@ -243,7 +243,7 @@ export const SensorComponent: React.FC = ({sensor, manual const displayValue = value !== undefined ? value.toFixed(1) : "--"; return ( -
+
= ({sensor, manual } const className = connected ? css.connectedValues : css.disconnectedValues; return ( -
+
{fragments}
); diff --git a/src/sensors/mock-sensor.ts b/src/sensors/mock-sensor.ts index 830d46b..f7ebb05 100644 --- a/src/sensors/mock-sensor.ts +++ b/src/sensors/mock-sensor.ts @@ -135,16 +135,20 @@ export class MockSensor extends Sensor { } public timeSeriesCapabilities(selectableSensorId: any): ITimeSeriesCapabilities { + selectableSensorId = parseInt(selectableSensorId ?? "0", 10); + const {measurement, units, minValue, maxValue} = selectableSensorId === 0 + ? {measurement: "Force", units: "N", minValue: -50, maxValue: 50} + : {measurement: "Temperature", units: "°C", minValue: -40, maxValue: 125}; const defaultMeasurementPeriod = 50; return { measurementPeriod: defaultMeasurementPeriod, minMeasurementPeriod: 10, defaultMeasurementPeriod, - measurement: "Fake Value", + measurement, valueKey: TimeSeriesDataKey, - units: "N/A", - minValue: -5, - maxValue: 5, + units, + minValue, + maxValue, }; }