fix: connectionLost state

This commit is contained in:
abdou6666 2025-05-01 15:58:08 +01:00
parent d913c23fbc
commit 5c487e1e12

View File

@ -405,11 +405,20 @@ const ChatProvider: React.FC<{
handleSubscription(profile.first_name, profile.last_name);
}
};
const endConnection = () => {
setConnectionState(0);
};
socketCtx.socket.io.on("reconnect", reSubscribe);
socketCtx.socket.io.on("close", endConnection);
socketCtx.socket.io.on("reconnect_error", endConnection);
socketCtx.socket.io.on("reconnect_failed", endConnection);
return () => {
socketCtx.socket.io.off("reconnect", reSubscribe);
socketCtx.socket.io.on("close", endConnection);
socketCtx.socket.io.on("reconnect_error", endConnection);
socketCtx.socket.io.on("reconnect_failed", endConnection);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);