NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Fix segments on motion review (#10370)
Josh Hawkinscac5bccbe75d
diff --git a/web/src/components/timeline/MotionSegment.tsx b/web/src/components/timeline/MotionSegment.tsxindex 2efdd73d06..c66bbfc0b0 100644--- a/web/src/components/timeline/MotionSegment.tsx+++ b/web/src/components/timeline/MotionSegment.tsx@@ -82,7 +82,19 @@ export function MotionSegment({return isMobile ? 30 : 50;}, []);- const segmentWidth = useMemo(() => {+ const firstHalfSegmentWidth = useMemo(() => {+ return interpolateMotionAudioData(+ getMotionSegmentValue(segmentTime),+ maxSegmentWidth,+ );+ }, [+ segmentTime,+ maxSegmentWidth,+ getMotionSegmentValue,+ interpolateMotionAudioData,+ ]);++ const secondHalfSegmentWidth = useMemo(() => {return interpolateMotionAudioData(getMotionSegmentValue(segmentTime + segmentDuration / 2),maxSegmentWidth,@@ -167,10 +179,19 @@ export function MotionSegment({};const segmentClick = useCallback(() => {- if (startTimestamp && setHandlebarTime && segmentWidth > 1) {+ if (+ startTimestamp &&+ setHandlebarTime &&+ (firstHalfSegmentWidth > 1 || secondHalfSegmentWidth > 1)+ ) {setHandlebarTime(startTimestamp);}- }, [startTimestamp, setHandlebarTime, segmentWidth]);+ }, [+ startTimestamp,+ setHandlebarTime,+ firstHalfSegmentWidth,+ secondHalfSegmentWidth,+ ]);return (<div@@ -204,7 +225,7 @@ export function MotionSegment({key={`${segmentKey}_motion_data_1`}className={`h-[2px] rounded-full bg-motion_review`}style={{- width: segmentWidth,+ width: secondHalfSegmentWidth,}}></div></div>@@ -216,7 +237,7 @@ export function MotionSegment({key={`${segmentKey}_motion_data_2`}className={`h-[2px] rounded-full bg-motion_review`}style={{- width: segmentWidth,+ width: firstHalfSegmentWidth,}}></div></div>diff --git a/web/src/hooks/use-motion-segment-utils.ts b/web/src/hooks/use-motion-segment-utils.tsindex 4cf0c15e17..dfec483588 100644--- a/web/src/hooks/use-motion-segment-utils.ts+++ b/web/src/hooks/use-motion-segment-utils.ts@@ -40,14 +40,20 @@ export const useMotionSegmentUtils = (const getMotionSegmentValue = useCallback((time: number): number => {- const matchingEvent = motion_events.find((event) => {+ const segmentStart = getSegmentStart(time);+ const segmentEnd = getSegmentEnd(time);+ const matchingEvents = motion_events.filter((event) => {return (- time >= getSegmentStart(event.start_time) &&- time <= getSegmentEnd(event.start_time)+ event.start_time >= segmentStart && event.start_time < segmentEnd);});- return matchingEvent?.motion ?? 0;+ const totalMotion = matchingEvents.reduce(+ (acc, curr) => acc + (curr.motion ?? 0),+ 0,+ );++ return totalMotion;},[motion_events, getSegmentStart, getSegmentEnd],);