From 6aee86182e50617967cef4a8c6b9d1710af35cc9 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sun, 22 May 2022 18:55:49 +0800 Subject: [PATCH] handel interval onlyShowAvaliable --- pages/time.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pages/time.js b/pages/time.js index 9426023..505a10c 100644 --- a/pages/time.js +++ b/pages/time.js @@ -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) { {ranges.map((range) => { - if (onlyShowAvaliable && range.name === "") { + if (onlyShowAvaliable && range.username !== "") { return; } return (