mirror of
https://github.com/hoornet/vega.git
synced 2026-07-23 00:38:10 -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:
@@ -4,7 +4,7 @@ import { useUserStore } from "../../stores/user";
|
||||
import { useUIStore } from "../../stores/ui";
|
||||
import { fetchZapsReceived, fetchZapsSent, fetchNoteById } from "../../lib/nostr";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import { timeAgo, shortenPubkey } from "../../lib/utils";
|
||||
import { timeAgo, shortenPubkey, profileName } from "../../lib/utils";
|
||||
|
||||
// ── Parsing helpers ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -53,9 +53,9 @@ function ZapRow({
|
||||
const { openProfile, openThread } = useUIStore();
|
||||
const profile = useProfile(pubkey ?? "");
|
||||
const name = pubkey
|
||||
? profile?.displayName || profile?.name || shortenPubkey(pubkey)
|
||||
? profileName(profile, shortenPubkey(pubkey))
|
||||
: "anonymous";
|
||||
const avatar = profile?.picture;
|
||||
const avatar = typeof profile?.picture === "string" ? profile.picture : undefined;
|
||||
const [notePreview, setNotePreview] = useState<string | null>(null);
|
||||
const [noteEvent, setNoteEvent] = useState<NDKEvent | null>(null);
|
||||
const [loadingNote, setLoadingNote] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user