mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: connectionLost state
This commit is contained in:
parent
d913c23fbc
commit
5c487e1e12
@ -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
|
||||
}, []);
|
||||
|
Loading…
Reference in New Issue
Block a user