diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index 8f62e881..f0893c4b 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -107,15 +107,12 @@ export const ActiveCall: FC = (props) => { props.e2eeConfig, ); - const cleanup = useCallback(() => { - if (connState === ConnectionState.Connected) { - livekitRoom?.disconnect(); - } - }, [livekitRoom, connState]); - useEffect(() => { - return cleanup; - }, [cleanup, livekitRoom]); + return () => { + livekitRoom?.disconnect(); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); if (!livekitRoom) return null; @@ -207,14 +204,6 @@ export const InCallView: FC = ({ (muted) => muteStates.audio.setEnabled?.(!muted), ); - const onLeavePress = useCallback(() => { - // Disconnect from the room. We don't do this in onLeave because that's - // also called on an unintentional disconnect. Plus we don't have the - // livekit room in onLeave anyway. - livekitRoom.disconnect(); - onLeave(); - }, [livekitRoom, onLeave]); - useEffect(() => { widget?.api.transport.send( layout === "grid" @@ -392,11 +381,7 @@ export const InCallView: FC = ({ } buttons.push( - , + , ); footer = (