mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-03 08:07:21 +00:00
Show all accounts in switcher; current user links to profile
This commit is contained in:
1 file changed
+26
-2
@@ -1,4 +1,6 @@
|
||||
import { ChevronDown, LogOut, UserIcon, UserPlus } from 'lucide-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
@@ -48,7 +50,30 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className='w-56 p-2 animate-scale-in'>
|
||||
<div className='font-medium text-sm px-2 py-1.5'>Switch Account</div>
|
||||
<DropdownMenuItem asChild className='flex items-center gap-2 cursor-pointer p-2 rounded-md'>
|
||||
<Link to={`/${nip19.npubEncode(currentUser.pubkey)}`}>
|
||||
<Avatar className='w-8 h-8'>
|
||||
<AvatarImage
|
||||
src={currentUser.metadata.picture}
|
||||
alt={isCurrentUserPending ? '' : getDisplayName(currentUser)}
|
||||
/>
|
||||
<AvatarFallback>
|
||||
{isCurrentUserPending ? (
|
||||
<Skeleton className='size-full rounded-full' />
|
||||
) : (
|
||||
getDisplayName(currentUser)?.charAt(0) || <UserIcon />
|
||||
)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className='flex-1 truncate'>
|
||||
{isCurrentUserPending ? (
|
||||
<Skeleton className='h-4 w-24' />
|
||||
) : (
|
||||
<p className='text-sm font-medium'>{getDisplayName(currentUser)}</p>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
{otherUsers.map((user) => {
|
||||
const isPending = isLoading && !user.metadata.name;
|
||||
return (
|
||||
@@ -77,7 +102,6 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {
|
||||
<p className='text-sm font-medium'>{getDisplayName(user)}</p>
|
||||
)}
|
||||
</div>
|
||||
{user.id === currentUser.id && <div className='w-2 h-2 rounded-full bg-primary'></div>}
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user