Only close MSE websocket when it's already open (#12078)

This commit is contained in:
Josh Hawkins 2024-06-20 06:03:14 -06:00 committed by GitHub
parent 5c33cdba4e
commit 9f81ce2876
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,12 +117,12 @@ function MSEPlayer({
}, [wsURL]);
const onDisconnect = useCallback(() => {
if (wsRef.current && wsState == WebSocket.OPEN) {
setWsState(WebSocket.CLOSED);
if (wsRef.current) {
wsRef.current.close();
wsRef.current = null;
}
}, []);
}, [wsState]);
const onOpen = () => {
setWsState(WebSocket.OPEN);