mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 22:57:40 +03:00
prevent motion recalibration when opening motion tuner
This commit is contained in:
parent
8f5698f261
commit
0cbc7efeaa
@ -4,7 +4,7 @@ import useSWR from "swr";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
import ActivityIndicator from "@/components/indicators/activity-indicator";
|
||||||
import AutoUpdatingCameraImage from "@/components/camera/AutoUpdatingCameraImage";
|
import AutoUpdatingCameraImage from "@/components/camera/AutoUpdatingCameraImage";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { Slider } from "@/components/ui/slider";
|
import { Slider } from "@/components/ui/slider";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import {
|
import {
|
||||||
@ -63,6 +63,8 @@ export default function MotionTunerView({
|
|||||||
improve_contrast: undefined,
|
improve_contrast: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const userInteractedRef = useRef(false);
|
||||||
|
|
||||||
const cameraConfig = useMemo(() => {
|
const cameraConfig = useMemo(() => {
|
||||||
if (config && selectedCamera) {
|
if (config && selectedCamera) {
|
||||||
return config.cameras[selectedCamera];
|
return config.cameras[selectedCamera];
|
||||||
@ -70,6 +72,7 @@ export default function MotionTunerView({
|
|||||||
}, [config, selectedCamera]);
|
}, [config, selectedCamera]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
userInteractedRef.current = false;
|
||||||
if (cameraConfig) {
|
if (cameraConfig) {
|
||||||
setMotionSettings({
|
setMotionSettings({
|
||||||
threshold: cameraConfig.motion.threshold,
|
threshold: cameraConfig.motion.threshold,
|
||||||
@ -87,24 +90,29 @@ export default function MotionTunerView({
|
|||||||
}, [selectedCamera]);
|
}, [selectedCamera]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!motionSettings.threshold) return;
|
if (!motionSettings.threshold || !userInteractedRef.current) return;
|
||||||
|
|
||||||
sendMotionThreshold(motionSettings.threshold);
|
sendMotionThreshold(motionSettings.threshold);
|
||||||
}, [motionSettings.threshold, sendMotionThreshold]);
|
}, [motionSettings.threshold, sendMotionThreshold]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!motionSettings.contour_area) return;
|
if (!motionSettings.contour_area || !userInteractedRef.current) return;
|
||||||
|
|
||||||
sendMotionContourArea(motionSettings.contour_area);
|
sendMotionContourArea(motionSettings.contour_area);
|
||||||
}, [motionSettings.contour_area, sendMotionContourArea]);
|
}, [motionSettings.contour_area, sendMotionContourArea]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (motionSettings.improve_contrast === undefined) return;
|
if (
|
||||||
|
motionSettings.improve_contrast === undefined ||
|
||||||
|
!userInteractedRef.current
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
sendImproveContrast(motionSettings.improve_contrast ? "ON" : "OFF");
|
sendImproveContrast(motionSettings.improve_contrast ? "ON" : "OFF");
|
||||||
}, [motionSettings.improve_contrast, sendImproveContrast]);
|
}, [motionSettings.improve_contrast, sendImproveContrast]);
|
||||||
|
|
||||||
const handleMotionConfigChange = (newConfig: Partial<MotionSettings>) => {
|
const handleMotionConfigChange = (newConfig: Partial<MotionSettings>) => {
|
||||||
|
userInteractedRef.current = true;
|
||||||
setMotionSettings((prevConfig) => ({ ...prevConfig, ...newConfig }));
|
setMotionSettings((prevConfig) => ({ ...prevConfig, ...newConfig }));
|
||||||
setUnsavedChanges(true);
|
setUnsavedChanges(true);
|
||||||
setChangedValue(true);
|
setChangedValue(true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user