From 04ee70034a651f16782882a4ae08d99a331e4a57 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Thu, 5 Dec 2024 16:27:04 +0100 Subject: [PATCH] fix: updated return on rtc-connection-events-hook --- .../production-line/use-rtc-connection.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/production-line/use-rtc-connection.ts b/src/components/production-line/use-rtc-connection.ts index a88e42dd..b0e29763 100644 --- a/src/components/production-line/use-rtc-connection.ts +++ b/src/components/production-line/use-rtc-connection.ts @@ -351,14 +351,16 @@ export const useRtcConnection = ({ // Debug hook for logging RTC events TODO remove useEffect(() => { - if ( - !rtcPeerConnectionRef.current || - rtcPeerConnectionRef.current.connectionState === "closed" - ) { - rtcPeerConnectionRef.current = new RTCPeerConnection(); - } const rtcPeerConnection = rtcPeerConnectionRef.current; + if (!rtcPeerConnection) { + return () => { + console.log( + "Exited debug hook for logging RTC events early, no rtcPeerConnection" + ); + }; + } + const onIceGathering = () => console.log("ice gathering:", rtcPeerConnection.iceGatheringState); const onIceConnection = () =>