fix profile save diff, masksAndZones delete, and config sync

This commit is contained in:
Josh Hawkins
2026-03-11 12:04:35 -05:00
parent 7925d120ae
commit 3cdb40610f
4 changed files with 50 additions and 7 deletions
+22 -5
View File
@@ -1098,6 +1098,7 @@ export default function Settings() {
async (camera: string, section: string, profile: string) => {
try {
await axios.put("config/set", {
requires_restart: 0,
config_data: {
cameras: {
[camera]: {
@@ -1197,16 +1198,31 @@ export default function Settings() {
if (currentSectionKey === "masksAndZones") {
try {
const profileData =
config?.cameras?.[selectedCamera]?.profiles?.[profileName];
if (!profileData) return;
// Only delete top-level keys that exist in the profile
const deletePayload: Record<string, string> = {};
if (profileData.zones !== undefined) {
deletePayload.zones = "";
}
if (profileData.motion !== undefined) {
deletePayload.motion = "";
}
if (profileData.objects !== undefined) {
deletePayload.objects = "";
}
if (Object.keys(deletePayload).length === 0) return;
await axios.put("config/set", {
requires_restart: 0,
config_data: {
cameras: {
[selectedCamera]: {
profiles: {
[profileName]: {
zones: "",
motion: { mask: "" },
objects: { mask: "", filters: "" },
},
[profileName]: deletePayload,
},
},
},
@@ -1229,6 +1245,7 @@ export default function Settings() {
[
selectedCamera,
currentSectionKey,
config,
handleSelectProfile,
handleDeleteProfileSection,
t,