No recordings indicator on History timeline (#20715)

* black background

* fix backend logic

* fixes

* ensure data being sent to api is segment aligned

* tweak

* tweaks to keep motion review as-is

* fix for half segment fractional seconds when using zooming
This commit is contained in:
Josh Hawkins
2025-10-29 08:39:07 -06:00
committed by GitHub
parent 9917fc3169
commit 61549a0151
9 changed files with 170 additions and 71 deletions
+9 -4
View File
@@ -43,9 +43,14 @@ export const useMotionSegmentUtils = (
const segmentStart = getSegmentStart(time);
const segmentEnd = getSegmentEnd(time);
const matchingEvents = motion_events.filter((event) => {
return (
event.start_time >= segmentStart && event.start_time < segmentEnd
);
// Use integer ms math to avoid floating point rounding issues
// when halfSegmentDuration is not an integer
// (eg, 2.5 seconds from timeline zooming)
const eventMs = Math.round(event.start_time * 1000);
const halfMs = Math.round(halfSegmentDuration * 1000);
const eventBucketMs = Math.round(eventMs / halfMs) * halfMs;
const eventRounded = eventBucketMs / 1000;
return eventRounded >= segmentStart && eventRounded < segmentEnd;
});
const totalMotion = matchingEvents.reduce(
@@ -55,7 +60,7 @@ export const useMotionSegmentUtils = (
return totalMotion;
},
[motion_events, getSegmentStart, getSegmentEnd],
[motion_events, getSegmentStart, getSegmentEnd, halfSegmentDuration],
);
const getAudioSegmentValue = useCallback(