Camera group url fixes (#20295)

* Fix group url param where a camera group was not always loaded

Need to use the loading state from the usePersistence hook because values are loaded from indexed db asynchronously

* ensure group icon changes when using url param

* clean up
This commit is contained in:
Josh Hawkins
2025-09-30 16:53:48 -06:00
committed by GitHub
parent 1b6c246a44
commit 16c88fa8ac
3 changed files with 10 additions and 4 deletions
+6 -2
View File
@@ -24,17 +24,21 @@ function Live() {
// selection
const [selectedCameraName, setSelectedCameraName] = useHashState();
const [cameraGroup, setCameraGroup] = usePersistedOverlayState(
const [cameraGroup, setCameraGroup, loaded, ,] = usePersistedOverlayState(
"cameraGroup",
"default" as string,
);
useSearchEffect("group", (cameraGroup) => {
if (config && cameraGroup) {
if (config && cameraGroup && loaded) {
const group = config.camera_groups[cameraGroup];
if (group) {
setCameraGroup(cameraGroup);
// return false so that url cleanup doesn't occur here.
// will be cleaned up by usePersistedOverlayState in the
// camera group selector so that the icon switches correctly
return false;
}
return true;