Tweaks and fixes (#11372)

* Ensure camera activity is up to date

* Persist playback rate between cameras

* Add setting for default playback rate

* Fix audio events saving image

* Formatting

* Use select component
This commit is contained in:
Nicolas Mowen
2024-05-14 07:38:03 -06:00
committed by GitHub
parent b451d0a4f1
commit b10ae68c1f
5 changed files with 111 additions and 39 deletions

View File

@@ -204,13 +204,26 @@ export function useFrigateStats(): { payload: FrigateStats } {
return { payload: JSON.parse(payload as string) };
}
export function useInitialCameraState(camera: string): {
export function useInitialCameraState(
camera: string,
refreshOnStart: boolean,
): {
payload: FrigateCameraState;
} {
const {
value: { payload },
} = useWs("camera_activity", "");
send: sendCommand,
} = useWs("camera_activity", "onConnect");
const data = JSON.parse(payload as string);
useEffect(() => {
if (refreshOnStart) {
sendCommand("onConnect");
}
// only refresh when onRefresh value changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [refreshOnStart]);
return { payload: data ? data[camera] : undefined };
}