mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Ensure detections are cleared when limit box is unchecked (#12412)
This commit is contained in:
parent
2ebd2dfcc7
commit
e7ec014502
@ -110,33 +110,36 @@ export default function CameraSettingsView({
|
|||||||
if (!isChecked) {
|
if (!isChecked) {
|
||||||
form.reset({
|
form.reset({
|
||||||
alerts_zones: watchedAlertsZones,
|
alerts_zones: watchedAlertsZones,
|
||||||
detections_zones:
|
detections_zones: [],
|
||||||
cameraConfig?.review.detections.required_zones || [],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setChangedValue(true);
|
setChangedValue(true);
|
||||||
setSelectDetections(isChecked as boolean);
|
setSelectDetections(isChecked as boolean);
|
||||||
},
|
},
|
||||||
[watchedAlertsZones, cameraConfig, form],
|
// we know that these deps are correct
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[watchedAlertsZones],
|
||||||
);
|
);
|
||||||
|
|
||||||
const saveToConfig = useCallback(
|
const saveToConfig = useCallback(
|
||||||
async (
|
async (
|
||||||
{ alerts_zones, detections_zones }: CameraReviewSettingsValueType, // values submitted via the form
|
{ alerts_zones, detections_zones }: CameraReviewSettingsValueType, // values submitted via the form
|
||||||
) => {
|
) => {
|
||||||
const alertQueries = [...alerts_zones]
|
const createQuery = (zones: string[], type: "alerts" | "detections") =>
|
||||||
.map(
|
zones.length
|
||||||
(zone) =>
|
? zones
|
||||||
`&cameras.${selectedCamera}.review.alerts.required_zones=${zone}`,
|
.map(
|
||||||
)
|
(zone) =>
|
||||||
.join("");
|
`&cameras.${selectedCamera}.review.${type}.required_zones=${zone}`,
|
||||||
|
)
|
||||||
|
.join("")
|
||||||
|
: cameraConfig?.review[type]?.required_zones &&
|
||||||
|
cameraConfig?.review[type]?.required_zones.length > 0
|
||||||
|
? `&cameras.${selectedCamera}.review.${type}.required_zones`
|
||||||
|
: "";
|
||||||
|
|
||||||
const detectionQueries = [...detections_zones]
|
const alertQueries = createQuery(alerts_zones, "alerts");
|
||||||
.map(
|
const detectionQueries = createQuery(detections_zones, "detections");
|
||||||
(zone) =>
|
|
||||||
`&cameras.${selectedCamera}.review.detections.required_zones=${zone}`,
|
|
||||||
)
|
|
||||||
.join("");
|
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.put(`config/set?${alertQueries}${detectionQueries}`, {
|
.put(`config/set?${alertQueries}${detectionQueries}`, {
|
||||||
@ -167,7 +170,7 @@ export default function CameraSettingsView({
|
|||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[updateConfig, setIsLoading, selectedCamera],
|
[updateConfig, setIsLoading, selectedCamera, cameraConfig],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onCancel = useCallback(() => {
|
const onCancel = useCallback(() => {
|
||||||
@ -188,7 +191,9 @@ export default function CameraSettingsView({
|
|||||||
setSelectDetections(
|
setSelectDetections(
|
||||||
!!cameraConfig?.review.detections.required_zones?.length,
|
!!cameraConfig?.review.detections.required_zones?.length,
|
||||||
);
|
);
|
||||||
}, [removeMessage, selectedCamera, setUnsavedChanges, form, cameraConfig]);
|
// we know that these deps are correct
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [removeMessage, selectedCamera, setUnsavedChanges, cameraConfig]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onCancel();
|
onCancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user