Fix live view updating when it shouldn't be (#11561)

* Simplify live image update logic

* Fix case where go2rtc is not setup
This commit is contained in:
Nicolas Mowen 2024-05-27 09:50:02 -06:00 committed by GitHub
parent c07f6999ca
commit a86e22e0fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,7 +80,7 @@ export default function LivePlayer({
// camera still state
const stillReloadInterval = useMemo(() => {
if (!windowVisible) {
if (!windowVisible || offline) {
return -1; // no reason to update the image when the window is not visible
}
@ -88,12 +88,12 @@ export default function LivePlayer({
return 60000;
}
if (cameraActive) {
if (activeMotion || activeTracking) {
return 200;
}
return 30000;
}, [liveReady, cameraActive, windowVisible]);
}, [liveReady, activeMotion, activeTracking, offline, windowVisible]);
if (!cameraConfig) {
return <ActivityIndicator />;
@ -135,6 +135,7 @@ export default function LivePlayer({
);
}
} else if (liveMode == "jsmpeg") {
if (cameraActive) {
player = (
<JSMpegPlayer
className="flex size-full justify-center overflow-hidden rounded-lg md:rounded-2xl"
@ -143,6 +144,9 @@ export default function LivePlayer({
height={cameraConfig.detect.height}
/>
);
} else {
player = null;
}
} else {
player = <ActivityIndicator />;
}