Disabled cameras fixing (#17273)

* Fix case where objects are returned as null

* Fix enabled status not being persisted

* Use config as source of truth when refreshed

* Ensure camera always have config object updated

* Cleanup typing
This commit is contained in:
Nicolas Mowen
2025-03-20 11:20:44 -05:00
committed by GitHub
parent d84fd324b2
commit d4d5c4aac8
7 changed files with 36 additions and 19 deletions
+4 -5
View File
@@ -44,7 +44,8 @@ function useValue(): useValueReturn {
return;
}
const cameraActivity: { [key: string]: object } = JSON.parse(activityValue);
const cameraActivity: { [key: string]: FrigateCameraState } =
JSON.parse(activityValue);
if (Object.keys(cameraActivity).length === 0) {
return;
@@ -64,9 +65,7 @@ function useValue(): useValueReturn {
autotracking,
alerts,
detections,
} =
// @ts-expect-error we know this is correct
state["config"];
} = state["config"];
cameraStates[`${name}/recordings/state`] = record ? "ON" : "OFF";
cameraStates[`${name}/enabled/state`] = enabled ? "ON" : "OFF";
cameraStates[`${name}/detect/state`] = detect ? "ON" : "OFF";
@@ -174,7 +173,7 @@ export function useEnabledState(camera: string): {
value: { payload },
send,
} = useWs(`${camera}/enabled/state`, `${camera}/enabled/set`);
return { payload: (payload ?? "ON") as ToggleableSetting, send };
return { payload: payload as ToggleableSetting, send };
}
export function useDetectState(camera: string): {