mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
fix eslint warnings
This commit is contained in:
@@ -27,7 +27,7 @@ import { useRowSelect } from '@table-library/react-table-library/select';
|
||||
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
|
||||
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
||||
import { useTheme } from '@table-library/react-table-library/theme';
|
||||
import { useState, useContext, useEffect } from 'react';
|
||||
import { useState, useContext, useEffect, useCallback } from 'react';
|
||||
|
||||
import { IconContext } from 'react-icons';
|
||||
import { toast } from 'react-toastify';
|
||||
@@ -183,24 +183,26 @@ const DashboardDevices: FC = () => {
|
||||
);
|
||||
|
||||
const fetchDeviceData = async (id: number) => {
|
||||
try {
|
||||
setDeviceData((await EMSESP.readDeviceData({ id })).data);
|
||||
} catch (error) {
|
||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
if (!deviceValueDialogOpen) {
|
||||
try {
|
||||
setDeviceData((await EMSESP.readDeviceData({ id })).data);
|
||||
} catch (error) {
|
||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const fetchCoreData = async () => {
|
||||
const fetchCoreData = useCallback(async () => {
|
||||
try {
|
||||
setCoreData((await EMSESP.readCoreData()).data);
|
||||
} catch (error) {
|
||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
}
|
||||
};
|
||||
}, [LL]);
|
||||
|
||||
useEffect(() => {
|
||||
void fetchCoreData();
|
||||
}, []);
|
||||
}, [fetchCoreData]);
|
||||
|
||||
const refreshData = () => {
|
||||
if (selectedDevice) {
|
||||
@@ -280,7 +282,7 @@ const DashboardDevices: FC = () => {
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, []);
|
||||
});
|
||||
|
||||
const deviceValueDialogSave = async (dv: DeviceValue) => {
|
||||
try {
|
||||
|
||||
@@ -102,16 +102,18 @@ const DashboardSensors: FC = () => {
|
||||
]);
|
||||
|
||||
const fetchSensorData = useCallback(async () => {
|
||||
try {
|
||||
setSensorData((await EMSESP.readSensorData()).data);
|
||||
} catch (error) {
|
||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
if (!analogDialogOpen && !temperatureDialogOpen) {
|
||||
try {
|
||||
setSensorData((await EMSESP.readSensorData()).data);
|
||||
} catch (error) {
|
||||
toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING()));
|
||||
}
|
||||
}
|
||||
}, [LL]);
|
||||
}, [LL, analogDialogOpen, temperatureDialogOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
void fetchSensorData();
|
||||
}, []);
|
||||
}, [fetchSensorData]);
|
||||
|
||||
const getSortIcon = (state: any, sortKey: any) => {
|
||||
if (state.sortKey === sortKey && state.reverse) {
|
||||
@@ -160,11 +162,11 @@ const DashboardSensors: FC = () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => fetchSensorData(), 60000);
|
||||
const timer = setInterval(() => fetchSensorData(), 30000);
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [fetchSensorData]);
|
||||
});
|
||||
|
||||
const formatDurationMin = (duration_min: number) => {
|
||||
const days = Math.trunc((duration_min * 60000) / 86400000);
|
||||
|
||||
@@ -213,7 +213,7 @@ const DashboardSensorsAnalogDialog = ({
|
||||
name="f"
|
||||
label={LL.FREQ()}
|
||||
value={numberValue(editItem.f)}
|
||||
// fullWidth
|
||||
fullWidth
|
||||
type="number"
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
@@ -228,7 +228,7 @@ const DashboardSensorsAnalogDialog = ({
|
||||
name="o"
|
||||
label={LL.DUTY_CYCLE()}
|
||||
value={numberValue(editItem.o)}
|
||||
// fullWidth
|
||||
fullWidth
|
||||
type="number"
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
|
||||
@@ -116,7 +116,7 @@ const DashboardStatus: FC = () => {
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, []);
|
||||
});
|
||||
|
||||
const showName = (id: any) => {
|
||||
const name: keyof Translation['STATUS_NAMES'] = id;
|
||||
|
||||
@@ -130,7 +130,7 @@ const SettingsEntities: FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
void fetchEntities();
|
||||
}, []);
|
||||
}, [fetchEntities]);
|
||||
|
||||
const saveEntities = async () => {
|
||||
if (entities) {
|
||||
|
||||
@@ -117,7 +117,6 @@ const SettingsScheduler: FC = () => {
|
||||
}
|
||||
}, [LL]);
|
||||
|
||||
// on mount
|
||||
useEffect(() => {
|
||||
const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' });
|
||||
const days = [1, 2, 3, 4, 5, 6, 7].map((day) => {
|
||||
|
||||
Reference in New Issue
Block a user