From 2d943c73d7576e2326120acf815dea2462e6732c Mon Sep 17 00:00:00 2001 From: Wolfgang Faust Date: Sun, 4 Dec 2022 22:18:39 -0800 Subject: [PATCH 1/5] www: refactor audio/video controls into separate components --- www/components/room/controls.tsx | 78 ++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/www/components/room/controls.tsx b/www/components/room/controls.tsx index 7142863..7ebebd9 100644 --- a/www/components/room/controls.tsx +++ b/www/components/room/controls.tsx @@ -36,8 +36,7 @@ function Control(props: ControlProps) { ); } -export default function Controls() { - const router = useRouter(); +function AudioControl() { const [local, setLocal] = useRecoilState(localState); const peers = useRecoilValue(peersState); const stream = mapGet(streamMap, LocalStreamKey); @@ -46,13 +45,6 @@ export default function Controls() { const { audioEnabled, videoEnabled } = getVideoAudioEnabled(stream); - const handleLeave = React.useCallback(() => { - router.push( - `/goodbye?left=${router.query.roomCode}/${router.query.roomName}`, - "/goodbye" - ); - }, [router]); - const handleToggleAudio = React.useCallback(() => { peers.forEach((peer) => { const channel = rtcDataChannelMap.get(peer.sid); @@ -76,6 +68,31 @@ export default function Controls() { setLocal(localActions.setAudioVideoEnabled(!audioEnabled, videoEnabled)); }, [audioEnabled, local.name, peers, setLocal, stream, videoEnabled]); + const audioIconClassName = classNames("absolute", { + "text-slate-800": !audioEnabled, + }); + + return ( + +