import { useChat } from '@/providers/ChatProvider' import { useFetchProfile } from '@/hooks/useFetchProfile' import { useSecondaryPage } from '@/PageManager' import { Pubkey } from '@/domain' import { X, MessageSquare, Shield, Crown } from 'lucide-react' import { Button } from '../ui/button' export default function MemberListPanel({ onClose }: { onClose: () => void }) { const { currentChannel, channelParticipants, channelMods } = useChat() if (!currentChannel) return null // Sort: owner first, then mods, then everyone else const sorted = [...channelParticipants].sort((a, b) => { const aOwner = a === currentChannel.creator ? 0 : 1 const bOwner = b === currentChannel.creator ? 0 : 1 if (aOwner !== bOwner) return aOwner - bOwner const aMod = channelMods.includes(a) ? 0 : 1 const bMod = channelMods.includes(b) ? 0 : 1 return aMod - bMod }) return (
Members ({sorted.length})
{sorted.map((pk) => ( ))}
) } function MemberItem({ pubkey, isOwner, isMod }: { pubkey: string isOwner: boolean isMod: boolean }) { const { profile } = useFetchProfile(pubkey) const { push } = useSecondaryPage() const pk = Pubkey.tryFromString(pubkey) const displayName = profile?.username || pk?.formatNpub(8) || pubkey.slice(0, 12) return (
{profile?.avatar && }
{displayName} {isOwner && } {isMod && !isOwner && }
) }