mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
fix data loading when dialog was open
This commit is contained in:
@@ -19,10 +19,11 @@ import {
|
|||||||
} from '@table-library/react-table-library/table';
|
} from '@table-library/react-table-library/table';
|
||||||
import { useTheme } from '@table-library/react-table-library/theme';
|
import { useTheme } from '@table-library/react-table-library/theme';
|
||||||
import type { State } from '@table-library/react-table-library/types/common';
|
import type { State } from '@table-library/react-table-library/types/common';
|
||||||
import { useAutoRequest, useRequest } from 'alova/client';
|
import { useRequest } from 'alova/client';
|
||||||
import { SectionContent, useLayoutTitle } from 'components';
|
import { SectionContent, useLayoutTitle } from 'components';
|
||||||
import { AuthenticatedContext } from 'contexts/authentication';
|
import { AuthenticatedContext } from 'contexts/authentication';
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
|
import { useInterval } from 'utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
readSensorData,
|
readSensorData,
|
||||||
@@ -59,7 +60,7 @@ const Sensors = () => {
|
|||||||
const [analogDialogOpen, setAnalogDialogOpen] = useState<boolean>(false);
|
const [analogDialogOpen, setAnalogDialogOpen] = useState<boolean>(false);
|
||||||
const [creating, setCreating] = useState<boolean>(false);
|
const [creating, setCreating] = useState<boolean>(false);
|
||||||
|
|
||||||
const { data: sensorData, send: fetchSensorData } = useAutoRequest(
|
const { data: sensorData, send: fetchSensorData } = useRequest(
|
||||||
() => readSensorData(),
|
() => readSensorData(),
|
||||||
{
|
{
|
||||||
initialData: {
|
initialData: {
|
||||||
@@ -67,8 +68,7 @@ const Sensors = () => {
|
|||||||
as: [],
|
as: [],
|
||||||
analog_enabled: false,
|
analog_enabled: false,
|
||||||
platform: 'ESP32'
|
platform: 'ESP32'
|
||||||
},
|
}
|
||||||
pollingTime: 3000
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -86,6 +86,12 @@ const Sensors = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useInterval(() => {
|
||||||
|
if (!temperatureDialogOpen && !analogDialogOpen) {
|
||||||
|
void fetchSensorData();
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
const common_theme = useTheme({
|
const common_theme = useTheme({
|
||||||
BaseRow: `
|
BaseRow: `
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|||||||
Reference in New Issue
Block a user