mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-27 13:47:50 +02:00
Fix camera enabled check (#17331)
* Fix camera enabled check * Add fix to LiveCameraView
This commit is contained in:
parent
1f98162377
commit
1e45f63a7c
@ -1,5 +1,5 @@
|
|||||||
import { useState, useCallback, useEffect, useMemo } from "react";
|
import { useState, useCallback, useEffect, useMemo } from "react";
|
||||||
import { useEnabledState } from "@/api/ws";
|
import { useCameraActivity } from "@/hooks/use-camera-activity";
|
||||||
import { IoIosWarning } from "react-icons/io";
|
import { IoIosWarning } from "react-icons/io";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@ -24,6 +24,7 @@ import { Checkbox } from "@/components/ui/checkbox";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import {
|
import {
|
||||||
FrigateConfig,
|
FrigateConfig,
|
||||||
|
CameraConfig,
|
||||||
GroupStreamingSettings,
|
GroupStreamingSettings,
|
||||||
StreamType,
|
StreamType,
|
||||||
} from "@/types/frigateConfig";
|
} from "@/types/frigateConfig";
|
||||||
@ -65,8 +66,9 @@ export function CameraStreamingDialog({
|
|||||||
// metadata
|
// metadata
|
||||||
|
|
||||||
// camera enabled state
|
// camera enabled state
|
||||||
const { payload: enabledState } = useEnabledState(camera);
|
const { enabled: isCameraEnabled } = useCameraActivity(
|
||||||
const cameraEnabled = enabledState === "ON";
|
config?.cameras[camera] ?? ({} as CameraConfig),
|
||||||
|
);
|
||||||
|
|
||||||
const isRestreamed = useMemo(
|
const isRestreamed = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@ -76,7 +78,7 @@ export function CameraStreamingDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
|
const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
|
||||||
cameraEnabled && isRestreamed ? `go2rtc/streams/${streamName}` : null,
|
isCameraEnabled && isRestreamed ? `go2rtc/streams/${streamName}` : null,
|
||||||
{
|
{
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
},
|
},
|
||||||
|
@ -112,6 +112,7 @@ import {
|
|||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { usePersistence } from "@/hooks/use-persistence";
|
import { usePersistence } from "@/hooks/use-persistence";
|
||||||
|
import { useCameraActivity } from "@/hooks/use-camera-activity";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
@ -143,8 +144,9 @@ export default function LiveCameraView({
|
|||||||
useResizeObserver(window);
|
useResizeObserver(window);
|
||||||
|
|
||||||
// camera enabled state
|
// camera enabled state
|
||||||
const { payload: enabledState } = useEnabledState(camera.name);
|
const { enabled: isCameraEnabled } = useCameraActivity(
|
||||||
const cameraEnabled = enabledState === "ON";
|
config?.cameras[camera.name] ?? ({} as CameraConfig),
|
||||||
|
);
|
||||||
|
|
||||||
// supported features
|
// supported features
|
||||||
const [streamName, setStreamName] = usePersistence<string>(
|
const [streamName, setStreamName] = usePersistence<string>(
|
||||||
@ -160,7 +162,7 @@ export default function LiveCameraView({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
|
const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
|
||||||
cameraEnabled && isRestreamed ? `go2rtc/streams/${streamName}` : null,
|
isCameraEnabled && isRestreamed ? `go2rtc/streams/${streamName}` : null,
|
||||||
{
|
{
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
},
|
},
|
||||||
@ -520,7 +522,7 @@ export default function LiveCameraView({
|
|||||||
setPip(false);
|
setPip(false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!cameraEnabled}
|
disabled={!isCameraEnabled}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{supports2WayTalk && (
|
{supports2WayTalk && (
|
||||||
@ -542,7 +544,7 @@ export default function LiveCameraView({
|
|||||||
setAudio(true);
|
setAudio(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!cameraEnabled}
|
disabled={!isCameraEnabled}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{supportsAudioOutput && preferredLiveMode != "jsmpeg" && (
|
{supportsAudioOutput && preferredLiveMode != "jsmpeg" && (
|
||||||
@ -559,7 +561,7 @@ export default function LiveCameraView({
|
|||||||
t("button.cameraAudio", { ns: "common" })
|
t("button.cameraAudio", { ns: "common" })
|
||||||
}
|
}
|
||||||
onClick={() => setAudio(!audio)}
|
onClick={() => setAudio(!audio)}
|
||||||
disabled={!cameraEnabled}
|
disabled={!isCameraEnabled}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<FrigateCameraFeatures
|
<FrigateCameraFeatures
|
||||||
@ -581,7 +583,7 @@ export default function LiveCameraView({
|
|||||||
setLowBandwidth={setLowBandwidth}
|
setLowBandwidth={setLowBandwidth}
|
||||||
supportsAudioOutput={supportsAudioOutput}
|
supportsAudioOutput={supportsAudioOutput}
|
||||||
supports2WayTalk={supports2WayTalk}
|
supports2WayTalk={supports2WayTalk}
|
||||||
cameraEnabled={cameraEnabled}
|
cameraEnabled={isCameraEnabled ?? false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user