mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Use refs for proper js closures in the liveReady timeout (#12464)
This commit is contained in:
parent
5c90f7dce7
commit
58dbbd5d29
@ -73,6 +73,15 @@ export default function LivePlayer({
|
|||||||
const liveMode = useCameraLiveMode(cameraConfig, preferredLiveMode);
|
const liveMode = useCameraLiveMode(cameraConfig, preferredLiveMode);
|
||||||
|
|
||||||
const [liveReady, setLiveReady] = useState(false);
|
const [liveReady, setLiveReady] = useState(false);
|
||||||
|
|
||||||
|
const liveReadyRef = useRef(liveReady);
|
||||||
|
const cameraActiveRef = useRef(cameraActive);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
liveReadyRef.current = liveReady;
|
||||||
|
cameraActiveRef.current = cameraActive;
|
||||||
|
}, [liveReady, cameraActive]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!autoLive || !liveReady) {
|
if (!autoLive || !liveReady) {
|
||||||
return;
|
return;
|
||||||
@ -80,7 +89,7 @@ export default function LivePlayer({
|
|||||||
|
|
||||||
if (!cameraActive) {
|
if (!cameraActive) {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
if (!cameraActive) {
|
if (liveReadyRef.current && !cameraActiveRef.current) {
|
||||||
setLiveReady(false);
|
setLiveReady(false);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -79,7 +79,7 @@ export default function LiveDashboardView({
|
|||||||
|
|
||||||
return cameras
|
return cameras
|
||||||
.map((cam) => cam.name)
|
.map((cam) => cam.name)
|
||||||
.filter((cam) => config.camera_groups[cameraGroup].cameras.includes(cam))
|
.filter((cam) => config.camera_groups[cameraGroup]?.cameras.includes(cam))
|
||||||
.join(",");
|
.join(",");
|
||||||
}, [cameras, cameraGroup, config, includeBirdseye]);
|
}, [cameras, cameraGroup, config, includeBirdseye]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user