diff --git a/src/components/app/SidebarChannels.tsx b/src/components/app/SidebarChannels.tsx index 28bafba..4c18047 100644 --- a/src/components/app/SidebarChannels.tsx +++ b/src/components/app/SidebarChannels.tsx @@ -1,10 +1,9 @@ "use client"; import { ScrollArea } from "../ui/scroll-area"; -import { Server, Channel } from "@/types/types"; +import { Channel } from "@/types/types"; import { Card } from "../ui/card"; -import { HashIcon, PhoneOff, Volume2Icon } from "lucide-react"; +import { HashIcon, Volume2Icon } from "lucide-react"; import App from "@/types/app"; -import { Button } from "../ui/button"; export function ChannelIcon({ kind }: { kind: "text" | "voice" }) { switch (kind) { @@ -50,15 +49,6 @@ export default function SidebarChannels({ app }: { app: App }) { ))} - - ); } diff --git a/src/components/channel/ChannelView.tsx b/src/components/channel/ChannelView.tsx index c5d0a21..775b3db 100644 --- a/src/components/channel/ChannelView.tsx +++ b/src/components/channel/ChannelView.tsx @@ -54,7 +54,7 @@ export default function ChannelView({ }} sendVoice={(data) => { while (!serverRef.current || serverRef.current?.CONNECTING) {} - sendVoice(serverRef.current, 0, data); + sendVoice(serverRef.current, data); }} indicators={indicators.filter( (indicator) => diff --git a/src/components/channel/VoiceBox.tsx b/src/components/channel/VoiceBox.tsx index 263437d..407272c 100644 --- a/src/components/channel/VoiceBox.tsx +++ b/src/components/channel/VoiceBox.tsx @@ -5,27 +5,72 @@ import { ClientMessage, IndicatorContext } from "@/types/protocol"; import { Message } from "@/types/types"; import { useEffect, useState } from "react"; import { startMic } from "@/lib/audio"; +import { Button } from "../ui/button"; +import { + ChevronLeftIcon, + PhoneCall, + PhoneOff, + Volume2Icon, +} from "lucide-react"; export default function VoiceBox({ sendVoice, + app, + channelName, }: { app: App; sendRequest: (req: ClientMessage) => void; channelName?: string; - channelIcon?: string; messages: Message[]; indicators: IndicatorContext[]; sendVoice: (data: Int16Array) => void; }) { + const [voiceConn, setVoiceConn] = useState(false); + useEffect(() => { + if (!voiceConn) return; + const stop = startMic(sendVoice); return () => { stop.then((s) => s()); }; - }, []); + }, [voiceConn]); return ( -
+