From efbc094bbc2d42aecc6777221112bd6ea03e998e Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 17 Oct 2023 19:18:06 -0600 Subject: [PATCH] Fixes for ongoing events (#8208) * Refresh ongoing and standard events * Collapse ongoing when props are set * Fix --- web/src/routes/Events.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index 55ab44f95..df3416cc8 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -94,7 +94,7 @@ export default function Events({ path, ...props }) { showDeleteFavorite: false, }); - const [showInProgress, setShowInProgress] = useState(true); + const [showInProgress, setShowInProgress] = useState((props.event || props.cameras || props.labels) == null); const eventsFetcher = useCallback( (path, params) => { @@ -121,8 +121,12 @@ export default function Events({ path, ...props }) { [searchParams] ); - const { data: ongoingEvents } = useSWR(['events', { in_progress: 1, include_thumbnails: 0 }]); - const { data: eventPages, mutate, size, setSize, isValidating } = useSWRInfinite(getKey, eventsFetcher); + const { data: ongoingEvents, mutate: refreshOngoingEvents } = useSWR(['events', { in_progress: 1, include_thumbnails: 0 }]); + const { data: eventPages, mutate: refreshEvents, size, setSize, isValidating } = useSWRInfinite(getKey, eventsFetcher); + const mutate = () => { + refreshEvents(); + refreshOngoingEvents(); + } const { data: allLabels } = useSWR(['labels']); const { data: allSubLabels } = useSWR(['sub_labels', { split_joined: 1 }]);