handel interval onlyShowAvaliable

This commit is contained in:
2022-05-22 18:55:49 +08:00
parent 25c556ea44
commit 6aee86182e

View File

@@ -141,8 +141,6 @@ export default function Time(props) {
};
const refreshRanges = () => {
getLimit();
getStats();
fetch(`${prefix}/api/time/ranges`)
.then((res) => res.json())
.then((res) => {
@@ -224,11 +222,17 @@ export default function Time(props) {
useEffect(() => {
refreshRanges();
getLimit();
getStats();
const interval = setInterval(() => {
refreshRanges();
getLimit();
getStats();
if (!onlyShowAvaliable) {
refreshRanges();
}
}, 1000);
return () => clearInterval(interval);
}, []);
}, [onlyShowAvaliable]);
/*
useEffect(() => {
@@ -357,7 +361,7 @@ export default function Time(props) {
</TableHead>
<TableBody>
{ranges.map((range) => {
if (onlyShowAvaliable && range.name === "") {
if (onlyShowAvaliable && range.username !== "") {
return;
}
return (