From 427c6a6afb4fc60c880d8f38c20818503e971c48 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:20:47 -0500 Subject: [PATCH] Timeline tweaks (#10816) * limit handles from overdragging when segments don't fill up timeline * use separate state for switch * add key --- .../components/filter/ReviewFilterGroup.tsx | 15 ++++++++----- .../components/timeline/ReviewTimeline.tsx | 6 +++++- web/src/hooks/use-draggable-element.ts | 21 +++++++++++++++---- web/src/views/events/EventView.tsx | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index 1803cac81..4d2e1db8e 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -2,7 +2,7 @@ import { Button } from "../ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; import useSWR from "swr"; import { CameraGroupConfig, FrigateConfig } from "@/types/frigateConfig"; -import { useCallback, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import { DropdownMenu, DropdownMenuContent, @@ -631,16 +631,21 @@ function ShowMotionOnlyButton({ motionOnly, setMotionOnly, }: ShowMotionOnlyButtonProps) { + const [motionOnlyButton, setMotionOnlyButton] = useState(motionOnly); + + useEffect( + () => setMotionOnly(motionOnlyButton), + [motionOnlyButton, setMotionOnly], + ); + return ( <>
{ - setMotionOnly(!motionOnly); - }} + checked={motionOnlyButton} + onCheckedChange={setMotionOnlyButton} />