From 5c52a1be7e6c52cf0942db1808e190f5baf674d7 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 8 Feb 2024 08:13:11 -0700 Subject: [PATCH] Remove active objects when they become stationary --- web/src/components/player/LivePlayer.tsx | 6 +++--- web/src/hooks/use-camera-activity.ts | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index f5e071c9f..4e23b698d 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -152,12 +152,12 @@ export default function LivePlayer({ } return ( -
+
{(showStillWithoutActivity == false || activeMotion || activeTracking) && player} {showStillWithoutActivity && !liveReady && ( -
+
2 || cameraConfig.detect.width / cameraConfig.detect.height < 1 - ? undefined + ? cameraConfig.detect.width / cameraConfig.detect.height : 16 / 9 } /> diff --git a/web/src/hooks/use-camera-activity.ts b/web/src/hooks/use-camera-activity.ts index 1493d6518..823220245 100644 --- a/web/src/hooks/use-camera-activity.ts +++ b/web/src/hooks/use-camera-activity.ts @@ -34,22 +34,26 @@ export default function useCameraActivity( return; } - if (event.type == "end") { - const eventIndex = activeObjects.indexOf(event.after.id); + const eventIndex = activeObjects.indexOf(event.after.id); + if (event.type == "end") { if (eventIndex != -1) { const newActiveObjects = [...activeObjects]; newActiveObjects.splice(eventIndex, 1); setActiveObjects(newActiveObjects); } } else { - if (!event.after.stationary) { - const eventIndex = activeObjects.indexOf(event.after.id); - - if (eventIndex == -1) { + if (eventIndex == -1) { + // add unknown event to list if not stationary + if (!event.after.stationary) { const newActiveObjects = [...activeObjects, event.after.id]; setActiveObjects(newActiveObjects); } + } else { + // remove known event from list if it has become stationary + if (event.after.stationary) { + activeObjects.splice(eventIndex, 1); + } } } }, [event, activeObjects]);