From 0e5abcb2db517552f34d94f6a1ee4ded48a61305 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 18 Jun 2026 11:39:32 +0700 Subject: [PATCH] fix: guard against undefined metadata in AccountSwitcher user.metadata can be undefined when the profile hasn't loaded yet. Changed all .metadata.x accesses to .metadata?.x to prevent crash. Co-authored-by: shakespeare.diy --- src/components/auth/AccountSwitcher.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/auth/AccountSwitcher.tsx b/src/components/auth/AccountSwitcher.tsx index a3d7b0c..5c71fd9 100644 --- a/src/components/auth/AccountSwitcher.tsx +++ b/src/components/auth/AccountSwitcher.tsx @@ -24,11 +24,11 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) { if (!currentUser) return null; const getDisplayName = (account: Account): string => { - return account.metadata.name ?? genUserName(account.pubkey); + return account.metadata?.name ?? genUserName(account.pubkey); } const getNip05 = (account: Account): string | undefined => { - return account.metadata.nip05; + return account.metadata?.nip05; } return ( @@ -37,7 +37,7 @@ export function AccountSwitcher({ onAddAccountClick }: AccountSwitcherProps) {