From ebcf25741b54cbd841a11d96a5a133f3d02b4fdd Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 4 Dec 2023 13:43:23 -0700 Subject: [PATCH] Fix timeline overlay for in progress events (#8852) --- web/src/components/TimelineSummary.jsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/web/src/components/TimelineSummary.jsx b/web/src/components/TimelineSummary.jsx index b3f32c3af..89b8914c3 100644 --- a/web/src/components/TimelineSummary.jsx +++ b/web/src/components/TimelineSummary.jsx @@ -34,10 +34,18 @@ export default function TimelineSummary({ event, onFrameSelected }) { const [timeIndex, setTimeIndex] = useState(-1); - const recordingParams = { - before: event.end_time || Date.now(), - after: event.start_time, - }; + const recordingParams = useMemo(() => { + if (!event.end_time) { + return { + after: event.start_time, + }; + } + + return { + before: event.end_time, + after: event.start_time, + }; + }, [event]); const { data: recordings } = useSWR([`${event.camera}/recordings`, recordingParams], { revalidateOnFocus: false }); // calculates the seek seconds by adding up all the seconds in the segments prior to the playback time