diff --git a/web/src/views/events/EventView.tsx b/web/src/views/events/EventView.tsx index d7997bf62..00024aa45 100644 --- a/web/src/views/events/EventView.tsx +++ b/web/src/views/events/EventView.tsx @@ -53,6 +53,7 @@ import { FilterList, LAST_24_HOURS_KEY } from "@/types/filter"; import { GiSoundWaves } from "react-icons/gi"; import useKeyboardListener from "@/hooks/use-keyboard-listener"; import ReviewDetailDialog from "@/components/overlay/detail/ReviewDetailDialog"; +import { useTimelineZoom } from "@/hooks/use-timeline-zoom"; type EventViewProps = { reviewItems?: SegmentedReviewData; @@ -461,8 +462,6 @@ function DetectionReview({ }: DetectionReviewProps) { const reviewTimelineRef = useRef(null); - const segmentDuration = 60; - // detail const [reviewDetail, setReviewDetail] = useState(); @@ -487,6 +486,33 @@ function DetectionReview({ // timeline interaction + const [zoomSettings, setZoomSettings] = useState({ + segmentDuration: 60, + timestampSpread: 15, + }); + + const possibleZoomLevels = useMemo( + () => [ + { segmentDuration: 60, timestampSpread: 15 }, + { segmentDuration: 30, timestampSpread: 5 }, + { segmentDuration: 10, timestampSpread: 1 }, + ], + [], + ); + + const handleZoomChange = useCallback( + (newZoomLevel: number) => { + setZoomSettings(possibleZoomLevels[newZoomLevel]); + }, + [possibleZoomLevels], + ); + + useTimelineZoom({ + zoomSettings, + zoomLevels: possibleZoomLevels, + onZoomChange: handleZoomChange, + }); + const timelineDuration = useMemo( () => timeRange.before - timeRange.after, [timeRange], @@ -494,7 +520,7 @@ function DetectionReview({ const { alignStartDateToTimeline, getVisibleTimelineDuration } = useTimelineUtils({ - segmentDuration, + segmentDuration: zoomSettings.segmentDuration, timelineDuration, timelineRef: reviewTimelineRef, }); @@ -692,7 +718,7 @@ function DetectionReview({ data-start={value.start_time} data-segment-start={ alignStartDateToTimeline(value.start_time) - - segmentDuration + zoomSettings.segmentDuration } className="review-item relative rounded-lg" > @@ -749,13 +775,13 @@ function DetectionReview({
-
+
{loading ? ( ) : ( @@ -1095,7 +1121,6 @@ function MotionReview({ setHandlebarTime={setCurrentTime} events={reviewItems?.all ?? []} motion_events={motionData ?? []} - severityType="significant_motion" contentRef={contentRef} onHandlebarDraggingChange={(scrubbing) => { if (playing && scrubbing) {