// NOTE: This file is stable and usually should not be modified. // It is important that all functionality in this file is preserved, and should only be modified if explicitly requested. import { ChevronDown, LogOut, UserIcon, UserPlus, Settings, HelpCircle } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu.tsx'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar.tsx'; import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts'; import { genUserName } from '@/lib/genUserName'; import { useNavigate } from 'react-router-dom'; interface AccountSwitcherProps { onAddAccountClick: () => void; } export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) { const { currentUser, otherUsers, setLogin, removeLogin } = useLoggedInAccounts(); const navigate = useNavigate(); if (!currentUser) return null; const getDisplayName = (account: Account): string => { return account.metadata.name ?? genUserName(account.pubkey); } return ( {otherUsers.length > 0 && ( <>
Switch Account
{otherUsers.map((user) => ( setLogin(user.id)} className='flex items-center gap-2 cursor-pointer p-2 rounded-md' > {getDisplayName(user)?.charAt(0) || }

{getDisplayName(user)}

{user.id === currentUser.id &&
}
))} )} navigate('/settings')} className='flex items-center gap-2 cursor-pointer p-2 rounded-md' > Settings window.open('https://soapbox.pub/shakespeare-resources/', '_blank')} className='flex items-center gap-2 cursor-pointer p-2 rounded-md' > Help Add another account removeLogin(currentUser.id)} className='flex items-center gap-2 cursor-pointer p-2 rounded-md text-red-500' > Log out
); }