diff --git a/src/components/NoteCard.tsx b/src/components/NoteCard.tsx index 831588bd..530b0109 100644 --- a/src/components/NoteCard.tsx +++ b/src/components/NoteCard.tsx @@ -226,14 +226,14 @@ export function NoteCard({ event, className, repostedBy, compact, threaded, thre const pTags = event.tags.filter(([name, , , marker]) => name === 'p' && marker !== 'mention'); if (pTags.length > 0) { - // Remove duplicates and return pubkeys - return [...new Set(pTags.map(([, pubkey]) => pubkey))]; + // Remove duplicates and filter out undefined/empty pubkeys + return [...new Set(pTags.map(([, pubkey]) => pubkey).filter(Boolean))] as string[]; } // Fallback: if all p tags are mentions, use all p tags anyway const allPTags = event.tags.filter(([name]) => name === 'p'); if (allPTags.length > 0) { - return [...new Set(allPTags.map(([, pubkey]) => pubkey))]; + return [...new Set(allPTags.map(([, pubkey]) => pubkey).filter(Boolean))] as string[]; } // Self-reply fallback: when replying to own post, no p tags are added (the diff --git a/src/components/ReplyContext.tsx b/src/components/ReplyContext.tsx index e1d1b085..6bce81e2 100644 --- a/src/components/ReplyContext.tsx +++ b/src/components/ReplyContext.tsx @@ -21,8 +21,10 @@ interface ReplyContextProps { * Used consistently across NoteCard and notification views. */ export function ReplyContext({ pubkeys, parentEventId, className }: ReplyContextProps) { + // Filter out any undefined/empty pubkeys defensively + const validPubkeys = pubkeys.filter(Boolean); // Show max 2 authors for cleaner UI - const displayPubkeys = pubkeys.slice(0, 2); + const displayPubkeys = validPubkeys.slice(0, 2); const replyingToLabel = parentEventId ? ( @@ -52,9 +54,9 @@ export function ReplyContext({ pubkeys, parentEventId, className }: ReplyContext {index < displayPubkeys.length - 1 && and} ))} - {pubkeys.length > 2 && ( + {validPubkeys.length > 2 && ( - and {pubkeys.length - 2} other{pubkeys.length - 2 !== 1 ? 's' : ''} + and {validPubkeys.length - 2} other{validPubkeys.length - 2 !== 1 ? 's' : ''} )}