Motion review improvements (#10833)

* render skeleton for preview player until motion data is loaded

* skeleton for timeline
This commit is contained in:
Josh Hawkins 2024-04-04 15:54:58 -05:00 committed by GitHub
parent 42559fa55d
commit 466a9104e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,6 +42,7 @@ import VideoControls from "@/components/player/VideoControls";
import { TimeRange } from "@/types/timeline"; import { TimeRange } from "@/types/timeline";
import { useCameraMotionNextTimestamp } from "@/hooks/use-camera-activity"; import { useCameraMotionNextTimestamp } from "@/hooks/use-camera-activity";
import useOptimisticState from "@/hooks/use-optimistic-state"; import useOptimisticState from "@/hooks/use-optimistic-state";
import { Skeleton } from "@/components/ui/skeleton";
type EventViewProps = { type EventViewProps = {
reviews?: ReviewSegment[]; reviews?: ReviewSegment[];
@ -837,6 +838,7 @@ function MotionReview({
const detectionType = getDetectionType(camera.name); const detectionType = getDetectionType(camera.name);
return ( return (
<div key={camera.name} className={`relative ${spans}`}> <div key={camera.name} className={`relative ${spans}`}>
{motionData ? (
<PreviewPlayer <PreviewPlayer
key={camera.name} key={camera.name}
className={`rounded-2xl ${spans} ${grow}`} className={`rounded-2xl ${spans} ${grow}`}
@ -851,11 +853,14 @@ function MotionReview({
onClick={() => onClick={() =>
onOpenRecording({ onOpenRecording({
camera: camera.name, camera: camera.name,
startTime: Math.min(currentTime, Date.now() / 1000 - 10), startTime: currentTime,
severity: "significant_motion", severity: "significant_motion",
}) })
} }
/> />
) : (
<Skeleton className={`rounded-2xl ${spans} ${grow}`} />
)}
<div <div
className={`review-item-ring pointer-events-none z-10 absolute rounded-lg inset-0 size-full -outline-offset-[2.8px] outline outline-[3px] ${detectionType ? `outline-severity_${detectionType} shadow-severity_${detectionType}` : "outline-transparent duration-500"}`} className={`review-item-ring pointer-events-none z-10 absolute rounded-lg inset-0 size-full -outline-offset-[2.8px] outline outline-[3px] ${detectionType ? `outline-severity_${detectionType} shadow-severity_${detectionType}` : "outline-transparent duration-500"}`}
/> />
@ -865,6 +870,7 @@ function MotionReview({
</div> </div>
</div> </div>
<div className="w-[55px] md:w-[100px] overflow-y-auto no-scrollbar"> <div className="w-[55px] md:w-[100px] overflow-y-auto no-scrollbar">
{motionData ? (
<MotionReviewTimeline <MotionReviewTimeline
segmentDuration={segmentDuration} segmentDuration={segmentDuration}
timestampSpread={15} timestampSpread={15}
@ -887,6 +893,9 @@ function MotionReview({
}} }}
dense={isMobile} dense={isMobile}
/> />
) : (
<Skeleton className="rounded-2xl size-full" />
)}
</div> </div>
<VideoControls <VideoControls