Fixes for ongoing events (#8208)

* Refresh ongoing and standard events

* Collapse ongoing when props are set

* Fix
This commit is contained in:
Nicolas Mowen 2023-10-17 19:18:06 -06:00 committed by GitHub
parent c7b2c6b95d
commit efbc094bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 }]);