From 77df8cc69b5fbd8c85ae7ad7ef38938c39c61bd2 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 31 Jan 2022 10:23:10 +0100 Subject: [PATCH] fix #340, refresh only device/sensor-data if open --- interface/src/project/DashboardData.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index f06f575d5..652248225 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -98,12 +98,11 @@ const DashboardData: FC = () => { const desktopWindow = useMediaQuery('(min-width:600px)'); - const refreshData = () => { + const refreshAllData = () => { if (analog || sensor || deviceValue) { return; } loadData(); - if (sensorData) { fetchSensorData(); } else if (selectedDevice) { @@ -111,6 +110,19 @@ const DashboardData: FC = () => { } }; + const refreshData = () => { + if (analog || sensor || deviceValue) { + return; + } + if (sensorData) { + fetchSensorData(); + } else if (selectedDevice) { + fetchDeviceData(selectedDevice); + } else { + loadData(); + } + }; + useEffect(() => { const timer = setInterval(() => refreshData(), 60000); return () => { @@ -407,6 +419,7 @@ const DashboardData: FC = () => { }; const toggleDeviceData = (index: number) => { + loadData(); if (selectedDevice === index) { setSelectedDevice(undefined); } else { @@ -415,6 +428,7 @@ const DashboardData: FC = () => { }; const toggleSensorData = () => { + loadData(); if (sensorData) { setSensorData(undefined); } else { @@ -810,7 +824,7 @@ const DashboardData: FC = () => { {renderSensorDialog()} {renderAnalogDialog()} -