mirror of
https://github.com/hoornet/vega.git
synced 2026-07-22 00:08:11 -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:
@@ -1,12 +1,12 @@
|
||||
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import { useUIStore } from "../../stores/ui";
|
||||
import { shortenPubkey, timeAgo } from "../../lib/utils";
|
||||
import { shortenPubkey, timeAgo, profileName } from "../../lib/utils";
|
||||
|
||||
function AncestorCard({ event }: { event: NDKEvent }) {
|
||||
const profile = useProfile(event.pubkey);
|
||||
const name = profile?.displayName || profile?.name || shortenPubkey(event.pubkey);
|
||||
const avatar = profile?.picture;
|
||||
const name = profileName(profile, shortenPubkey(event.pubkey));
|
||||
const avatar = typeof profile?.picture === "string" ? profile.picture : undefined;
|
||||
const time = event.created_at ? timeAgo(event.created_at) : "";
|
||||
const { openThread } = useUIStore();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user