From a978adc5a9b502941d90c80f6d51d67a07077c5a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 28 Feb 2024 07:16:32 -0700 Subject: [PATCH] Fix reload (#10109) * Fix reloading data * Don't show new review data when not looking at last 24 hours * Fix refresh button and no items text * Cleanup --- web/src/pages/Events.tsx | 12 +++++------- web/src/pages/Logs.tsx | 7 ++++--- web/src/views/events/EventView.tsx | 26 +++++++++++++++----------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/web/src/pages/Events.tsx b/web/src/pages/Events.tsx index f3d185c16..fc821a06f 100644 --- a/web/src/pages/Events.tsx +++ b/web/src/pages/Events.tsx @@ -28,9 +28,10 @@ export default function Events() { // review paging + const [beforeTs, setBeforeTs] = useState(Date.now() / 1000); const last24Hours = useMemo(() => { - return { before: Date.now() / 1000, after: getHoursAgo(24) }; - }, []); + return { before: beforeTs, after: getHoursAgo(24) }; + }, [beforeTs]); const selectedTimeRange = useMemo(() => { if (reviewSearchParams["after"] == undefined) { return last24Hours; @@ -73,7 +74,7 @@ export default function Events() { }; return ["review", params]; }, - [reviewSearchParams] + [reviewSearchParams, last24Hours] ); const { @@ -96,10 +97,7 @@ export default function Events() { setSize(size + 1); }, [size]); - const reloadData = useCallback(() => { - setSize(1); - updateSegments(); - }, []); + const reloadData = useCallback(() => setBeforeTs(Date.now() / 1000), []); // preview videos diff --git a/web/src/pages/Logs.tsx b/web/src/pages/Logs.tsx index f912ed3b5..591fe30f9 100644 --- a/web/src/pages/Logs.tsx +++ b/web/src/pages/Logs.tsx @@ -97,8 +97,9 @@ function Logs() { {!endVisible && ( -
contentRef.current?.scrollTo({ top: contentRef.current?.scrollHeight, @@ -107,7 +108,7 @@ function Logs() { } > Jump to Bottom -
+ )}
- + {isMobile && ( + + )} - + {filter?.before == undefined && ( + + )} - {reachedEnd && currentItems == null && ( + {!isValidating && currentItems == null && (
There are no {severity} items to review @@ -287,9 +291,9 @@ export default function EventView({
); }) - ) : ( + ) : severity != "alert" ? (
- )} + ) : null}