Fix timeline overlay for in progress events (#8852)

This commit is contained in:
Nicolas Mowen 2023-12-04 13:43:23 -07:00 committed by GitHub
parent eed08f534f
commit ebcf25741b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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