mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
ensure speed estimation is disabled when user adds more than 4 points
This commit is contained in:
parent
e163a2f178
commit
6af95b7487
@ -90,7 +90,7 @@ export default function ZoneEditPane({
|
|||||||
|
|
||||||
return Array.isArray(distances)
|
return Array.isArray(distances)
|
||||||
? distances.map((value) => parseFloat(value) || 0)
|
? distances.map((value) => parseFloat(value) || 0)
|
||||||
: [0, 0, 0, 0];
|
: [undefined, undefined, undefined, undefined];
|
||||||
}, [polygon, config]);
|
}, [polygon, config]);
|
||||||
|
|
||||||
const formSchema = z
|
const formSchema = z
|
||||||
@ -197,7 +197,7 @@ export default function ZoneEditPane({
|
|||||||
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
mode: "onChange",
|
mode: "onBlur",
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: polygon?.name ?? "",
|
name: polygon?.name ?? "",
|
||||||
inertia:
|
inertia:
|
||||||
@ -218,6 +218,19 @@ export default function ZoneEditPane({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
form.watch("speedEstimation") &&
|
||||||
|
polygon &&
|
||||||
|
polygon.points.length !== 4
|
||||||
|
) {
|
||||||
|
toast.error(
|
||||||
|
"Speed estimation has been disabled for this zone. Zones with speed estimation must have exactly 4 points.",
|
||||||
|
);
|
||||||
|
form.setValue("speedEstimation", false);
|
||||||
|
}
|
||||||
|
}, [polygon, form]);
|
||||||
|
|
||||||
const saveToConfig = useCallback(
|
const saveToConfig = useCallback(
|
||||||
async (
|
async (
|
||||||
{
|
{
|
||||||
@ -746,7 +759,9 @@ export function ZoneObjectSelector({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateLabelFilter(currentLabels);
|
updateLabelFilter(currentLabels);
|
||||||
}, [currentLabels, updateLabelFilter]);
|
// we know that these deps are correct
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [currentLabels]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user