From 435aab09be4726390d716670065dae173a86b1b4 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 4 Mar 2024 17:37:19 -0700 Subject: [PATCH] fix typing --- .../timeline/MotionReviewTimeline.tsx | 5 ++-- web/src/pages/UIPlayground.tsx | 28 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/web/src/components/timeline/MotionReviewTimeline.tsx b/web/src/components/timeline/MotionReviewTimeline.tsx index 900ceb98d..6cacc0deb 100644 --- a/web/src/components/timeline/MotionReviewTimeline.tsx +++ b/web/src/components/timeline/MotionReviewTimeline.tsx @@ -9,9 +9,8 @@ import { } from "react"; import MotionSegment from "./MotionSegment"; import { useEventUtils } from "@/hooks/use-event-utils"; -import { ReviewSegment, ReviewSeverity } from "@/types/review"; +import { MotionData, ReviewSegment, ReviewSeverity } from "@/types/review"; import ReviewTimeline from "./ReviewTimeline"; -import { MockMotionData } from "@/pages/UIPlayground"; export type MotionReviewTimelineProps = { segmentDuration: number; @@ -25,7 +24,7 @@ export type MotionReviewTimelineProps = { minimapStartTime?: number; minimapEndTime?: number; events: ReviewSegment[]; - motion_events: MockMotionData[]; + motion_events: MotionData[]; severityType: ReviewSeverity; contentRef: RefObject; onHandlebarDraggingChange?: (isDragging: boolean) => void; diff --git a/web/src/pages/UIPlayground.tsx b/web/src/pages/UIPlayground.tsx index 10306e07e..bbfe211b9 100644 --- a/web/src/pages/UIPlayground.tsx +++ b/web/src/pages/UIPlayground.tsx @@ -4,7 +4,12 @@ import useSWR from "swr"; import { FrigateConfig } from "@/types/frigateConfig"; import ActivityIndicator from "@/components/indicators/activity-indicator"; import EventReviewTimeline from "@/components/timeline/EventReviewTimeline"; -import { ReviewData, ReviewSegment, ReviewSeverity } from "@/types/review"; +import { + MotionData, + ReviewData, + ReviewSegment, + ReviewSeverity, +} from "@/types/review"; import { Button } from "@/components/ui/button"; import CameraActivityIndicator from "@/components/indicators/CameraActivityIndicator"; import MotionReviewTimeline from "@/components/timeline/MotionReviewTimeline"; @@ -53,14 +58,7 @@ function ColorSwatch({ name, value }: { name: string; value: string }) { ); } -export type MockMotionData = { - start_time: number; - end_time: number; - motionValue: number; - audioValue: number; -}; - -function generateRandomMotionAudioData(): MockMotionData[] { +function generateRandomMotionAudioData(): MotionData[] { const now = new Date(); const endTime = now.getTime() / 1000; const startTime = endTime - 24 * 60 * 60; // 24 hours ago @@ -72,14 +70,12 @@ function generateRandomMotionAudioData(): MockMotionData[] { startTimestamp < endTime; startTimestamp += interval ) { - const endTimestamp = startTimestamp + interval; - const motionValue = Math.floor(Math.random() * 101); // Random number between 0 and 100 - const audioValue = Math.random() * -100; // Random negative value between -100 and 0 + const motion = Math.floor(Math.random() * 101); // Random number between 0 and 100 + const audio = Math.random() * -100; // Random negative value between -100 and 0 data.push({ start_time: startTimestamp, - end_time: endTimestamp, - motionValue, - audioValue, + motion, + audio, }); } @@ -126,7 +122,7 @@ function UIPlayground() { const { data: config } = useSWR("config"); const contentRef = useRef(null); const [mockEvents, setMockEvents] = useState([]); - const [mockMotionData, setMockMotionData] = useState([]); + const [mockMotionData, setMockMotionData] = useState([]); const [handlebarTime, setHandlebarTime] = useState( Math.floor(Date.now() / 1000) - 15 * 60, );