mirror of
https://github.com/hoornet/vega.git
synced 2026-05-09 13:49:12 -07:00
Fix React error #31 crash from malformed Nostr profiles
Malformed profiles with non-string fields (e.g. nip05: {}) crashed
React's entire render tree in production. Add typeof guards and
profileName() utility across all components that render profile data.
Add ErrorBoundary in main.tsx to show crash details instead of blank screen.
This commit is contained in:
@@ -11,3 +11,9 @@ export function timeAgo(timestamp: number): string {
|
||||
export function shortenPubkey(pubkey: string): string {
|
||||
return pubkey.slice(0, 8) + "…" + pubkey.slice(-4);
|
||||
}
|
||||
|
||||
/** Safely extract display name from a Nostr profile (handles non-string values from malformed profiles). */
|
||||
export function profileName(profile: any, fallback: string): string {
|
||||
const raw = profile?.displayName || profile?.name;
|
||||
return (typeof raw === "string" ? raw : null) || fallback;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user