Skip to content

NVR with realtime local object detection for IP cameras

Re-send camera states after websocket disconnects and reconnects (#14847)

Josh Hawkins15bd26c9b190
diff --git a/web/src/api/ws.tsx b/web/src/api/ws.tsx
index b0c89d5ddf..c7bb74095b 100644
--- a/web/src/api/ws.tsx
+++ b/web/src/api/ws.tsx
@@ -69,7 +69,10 @@ function useValue(): useValueReturn {
...prevState,
...cameraStates,
}));
- setHasCameraState(true);
+
+ 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]);
@@ -93,6 +96,9 @@ function useValue(): useValueReturn {
retain: false,
});
},
+ onClose: () => {
+ setHasCameraState(false);
+ },
shouldReconnect: () => true,
retryOnError: true,
});