import React from 'react'; import { useVoiceStore } from '../../stores/voiceStore'; const EMPTY_VOICE_USERS: string[] = []; import { useServerStore } from '../../stores/serverStore'; import { Avatar } from '../ui/Avatar'; interface VoiceChannelProps { channelId: string; channelName: string; onClick: () => void; } export function VoiceChannel({ channelId, channelName, onClick }: VoiceChannelProps) { const voiceUsers = useVoiceStore((s) => s.voiceUsers.get(channelId)) ?? EMPTY_VOICE_USERS; const currentVoiceChannel = useVoiceStore((s) => s.currentVoiceChannelId); const members = useServerStore((s) => s.members); const isActive = currentVoiceChannel === channelId; return (
{/* Connected users */} {voiceUsers.length > 0 && (
{voiceUsers.map((userId) => { const member = members.find(m => m.userId === userId); if (!member) return null; const displayName = member.user.displayName ?? member.user.username; return (
{displayName}
); })}
)}
); }