mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 13:34:13 +03:00
Change camera_activity effect to run only when config updates (#20468)
This commit is contained in:
parent
6caa2050ff
commit
3c3e11ecaf
@ -33,14 +33,9 @@ function useValue(): useValueReturn {
|
|||||||
|
|
||||||
// main state
|
// main state
|
||||||
|
|
||||||
const [hasCameraState, setHasCameraState] = useState(false);
|
|
||||||
const [wsState, setWsState] = useState<WsState>({});
|
const [wsState, setWsState] = useState<WsState>({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasCameraState) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const activityValue: string = wsState["camera_activity"] as string;
|
const activityValue: string = wsState["camera_activity"] as string;
|
||||||
|
|
||||||
if (!activityValue) {
|
if (!activityValue) {
|
||||||
@ -105,12 +100,9 @@ function useValue(): useValueReturn {
|
|||||||
...cameraStates,
|
...cameraStates,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (Object.keys(cameraStates).length > 0) {
|
|
||||||
setHasCameraState(true);
|
|
||||||
}
|
|
||||||
// we only want this to run initially when the config is loaded
|
// we only want this to run initially when the config is loaded
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [wsState]);
|
}, [wsState["camera_activity"]]);
|
||||||
|
|
||||||
// ws handler
|
// ws handler
|
||||||
const { sendJsonMessage, readyState } = useWebSocket(wsUrl, {
|
const { sendJsonMessage, readyState } = useWebSocket(wsUrl, {
|
||||||
@ -131,9 +123,7 @@ function useValue(): useValueReturn {
|
|||||||
retain: false,
|
retain: false,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onClose: () => {
|
onClose: () => {},
|
||||||
setHasCameraState(false);
|
|
||||||
},
|
|
||||||
shouldReconnect: () => true,
|
shouldReconnect: () => true,
|
||||||
retryOnError: true,
|
retryOnError: true,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user