NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Change camera_activity effect to run only when config updates (#20468)
Josh Hawkins3c3e11ecaf6d
diff --git a/web/src/api/ws.tsx b/web/src/api/ws.tsxindex 8ebc017275..302f3f2632 100644--- a/web/src/api/ws.tsx+++ b/web/src/api/ws.tsx@@ -33,14 +33,9 @@ function useValue(): useValueReturn {// main state- const [hasCameraState, setHasCameraState] = useState(false);const [wsState, setWsState] = useState<WsState>({});useEffect(() => {- if (hasCameraState) {- return;- }-const activityValue: string = wsState["camera_activity"] as string;if (!activityValue) {@@ -105,12 +100,9 @@ function useValue(): useValueReturn {...cameraStates,}));- if (Object.keys(cameraStates).length > 0) {- setHasCameraState(true);- }// we only want this to run initially when the config is loaded// eslint-disable-next-line react-hooks/exhaustive-deps- }, [wsState]);+ }, [wsState["camera_activity"]]);// ws handlerconst { sendJsonMessage, readyState } = useWebSocket(wsUrl, {@@ -131,9 +123,7 @@ function useValue(): useValueReturn {retain: false,});},- onClose: () => {- setHasCameraState(false);- },+ onClose: () => {},shouldReconnect: () => true,retryOnError: true,});