diff --git a/README.md b/README.md
index a8db7e94..d1952462 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-
+
diff --git a/package.json b/package.json
index 30e67dc3..53e0fb89 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ui",
- "version": "0.24.7",
+ "version": "0.24.8",
"private": true,
"scripts": {
"dev": "react-scripts start",
diff --git a/src/contexts/RobotContext.tsx b/src/contexts/RobotContext.tsx
index 322052e0..8a8a1260 100644
--- a/src/contexts/RobotContext.tsx
+++ b/src/contexts/RobotContext.tsx
@@ -180,30 +180,30 @@ export default ({ children }: any) => {
// ROS Bridge Connector
useEffect(() => {
- if (
+ const rosClient: ROSLIB.Ros | null =
isSettedCookie &&
responseRobot?.bridgeIngressEndpoint?.split("://")[0] === "wss" &&
!envApplication
- ) {
- const rosClient: ROSLIB.Ros = new ROSLIB.Ros({
- url: responseRobot?.bridgeIngressEndpoint,
- });
+ ? new ROSLIB.Ros({
+ url: responseRobot?.bridgeIngressEndpoint,
+ })
+ : null;
- setRos(ros);
+ setRos(ros);
- rosClient?.on("connection", function () {
- setIsRosConnected(true);
- });
- rosClient?.on("error", function (error) {
- setIsRosConnected(false);
- });
- rosClient?.on("close", function () {
- setIsRosConnected(false);
- });
- }
+ ros?.on("connection", function () {
+ isRosConnected === null && setIsRosConnected(true);
+ });
+ ros?.on("error", function (error) {
+ isRosConnected === null && setIsRosConnected(false);
+ });
+ ros?.on("close", function () {
+ isRosConnected === null && setIsRosConnected(false);
+ });
return () => {
ros?.close();
+ rosClient?.close();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [responseRobot, isSettedCookie]);