mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-15 19:42:08 +03:00
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
This commit is contained in:
parent
923412ec1c
commit
c10229da5d
@ -109,7 +109,7 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
|
||||
|
||||
// groups
|
||||
|
||||
const [group, setGroup, deleteGroup] = usePersistedOverlayState(
|
||||
const [group, setGroup, , deleteGroup] = usePersistedOverlayState(
|
||||
"cameraGroup",
|
||||
"default" as string,
|
||||
);
|
||||
|
||||
@ -40,6 +40,7 @@ export function usePersistedOverlayState<S extends string>(
|
||||
): [
|
||||
S | undefined,
|
||||
(value: S | undefined, replace?: boolean) => void,
|
||||
boolean,
|
||||
() => void,
|
||||
] {
|
||||
const location = useLocation();
|
||||
@ -55,7 +56,7 @@ export function usePersistedOverlayState<S extends string>(
|
||||
|
||||
// saved value from previous session
|
||||
|
||||
const [persistedValue, setPersistedValue, , deletePersistedValue] =
|
||||
const [persistedValue, setPersistedValue, loaded, deletePersistedValue] =
|
||||
usePersistence<S>(key, overlayStateValue);
|
||||
|
||||
const setOverlayStateValue = useCallback(
|
||||
@ -73,6 +74,7 @@ export function usePersistedOverlayState<S extends string>(
|
||||
return [
|
||||
overlayStateValue ?? persistedValue ?? defaultValue,
|
||||
setOverlayStateValue,
|
||||
loaded,
|
||||
deletePersistedValue,
|
||||
];
|
||||
}
|
||||
|
||||
@ -24,13 +24,13 @@ 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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user