unselect all targets for existing camera

This commit is contained in:
Josh Hawkins 2026-05-28 09:01:26 -05:00
parent 05256b696c
commit 01e75ca99e

View File

@ -90,9 +90,9 @@ function stripAutoDefaultFilters(
/** /**
* Strip named runtime-only fields from each entry in a dict-of-objects * Strip named runtime-only fields from each entry in a dict-of-objects
* (mask `enabled_in_config`, zone `color`). The settings UI doesn't need * (mask `enabled_in_config`/`raw_coordinates`, zone `color`). The settings
* this because BaseSection's form never exposes these sub-collections; * UI doesn't need this because BaseSection's form never exposes these
* we do because clone re-injects them from the API response. * sub-collections; we do because clone re-injects them from the API.
*/ */
function stripDictEntryFields( function stripDictEntryFields(
dict: unknown, dict: unknown,
@ -335,29 +335,18 @@ export function resolutionsMatch(
} }
/** /**
* Initial selection set. Spatial categories default off on existing-camera * Initial selection set. Existing-camera targets start empty copying onto
* targets when resolutions differ (polygons may not align); otherwise each * a configured camera is destructive, so the user opts in explicitly.
* category uses its `defaultOnExisting`. `forcedForNewCamera` is always on * New-camera targets pre-select `defaultOnExisting` categories plus
* for new-camera targets. * `forcedForNewCamera`.
*/ */
export function getCategoryDefaults( export function getCategoryDefaults(
targetIsNew: boolean, targetIsNew: boolean,
resolutionMatches: boolean,
): Set<CloneCategoryKey> { ): Set<CloneCategoryKey> {
const selected = new Set<CloneCategoryKey>(); const selected = new Set<CloneCategoryKey>();
if (!targetIsNew) return selected;
for (const cat of CLONE_CATEGORIES) { for (const cat of CLONE_CATEGORIES) {
if (cat.newCameraOnly && !targetIsNew) continue; if (cat.forcedForNewCamera || cat.defaultOnExisting) selected.add(cat.key);
if (targetIsNew && cat.forcedForNewCamera) {
selected.add(cat.key);
continue;
}
if (cat.group === "spatial") {
if (targetIsNew || resolutionMatches) {
if (cat.defaultOnExisting) selected.add(cat.key);
}
continue;
}
if (cat.defaultOnExisting) selected.add(cat.key);
} }
return selected; return selected;
} }
@ -595,7 +584,10 @@ export function buildClonedCameraPayloads({
if (srcMask !== undefined) { if (srcMask !== undefined) {
pendingSectionValue = { pendingSectionValue = {
...(pendingSectionValue as object), ...(pendingSectionValue as object),
mask: stripDictEntryFields(srcMask, ["enabled_in_config"]), mask: stripDictEntryFields(srcMask, [
"enabled_in_config",
"raw_coordinates",
]),
}; };
} }
} }
@ -604,7 +596,10 @@ export function buildClonedCameraPayloads({
if (srcMask !== undefined) { if (srcMask !== undefined) {
pendingSectionValue = { pendingSectionValue = {
...(pendingSectionValue as object), ...(pendingSectionValue as object),
mask: stripDictEntryFields(srcMask, ["enabled_in_config"]), mask: stripDictEntryFields(srcMask, [
"enabled_in_config",
"raw_coordinates",
]),
}; };
} }
} }
@ -637,6 +632,7 @@ export function buildClonedCameraPayloads({
sanitizedOverrides: { sanitizedOverrides: {
mask: stripDictEntryFields(srcMask, [ mask: stripDictEntryFields(srcMask, [
"enabled_in_config", "enabled_in_config",
"raw_coordinates",
]) as JsonValue, ]) as JsonValue,
}, },
updateTopic: `config/cameras/${target}/${cameraUpdateTopicMap.motion}`, updateTopic: `config/cameras/${target}/${cameraUpdateTopicMap.motion}`,
@ -653,6 +649,7 @@ export function buildClonedCameraPayloads({
sanitizedOverrides: { sanitizedOverrides: {
mask: stripDictEntryFields(srcMask, [ mask: stripDictEntryFields(srcMask, [
"enabled_in_config", "enabled_in_config",
"raw_coordinates",
]) as JsonValue, ]) as JsonValue,
}, },
updateTopic: `config/cameras/${target}/${cameraUpdateTopicMap.objects}`, updateTopic: `config/cameras/${target}/${cameraUpdateTopicMap.objects}`,