From a63bd7b233128e1d7478efc01a261c439edde192 Mon Sep 17 00:00:00 2001 From: smolgrrr Date: Tue, 27 Aug 2024 14:46:45 +1000 Subject: [PATCH] tag fixs and thread format --- client/src/components/forms/PostFormCard.tsx | 24 +++++++++++++------- client/src/components/routes/Thread.tsx | 13 +++++++---- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/client/src/components/forms/PostFormCard.tsx b/client/src/components/forms/PostFormCard.tsx index 2594787..c74e98f 100644 --- a/client/src/components/forms/PostFormCard.tsx +++ b/client/src/components/forms/PostFormCard.tsx @@ -42,18 +42,26 @@ const NewNoteCard = ({ } if (refEvent && tagType) { - unsigned.tags = Array.from(new Set(unsigned.tags.concat(refEvent.tags.filter(tag => tag[0] === 'e' || tag[0] === 'p')))); unsigned.tags.push(['p', refEvent.pubkey]); - - if (tagType === 'Reply') { + const addEventTags = () => { + unsigned.tags = Array.from(new Set([ + ...unsigned.tags, + ...refEvent.tags.filter(tag => tag[0] === 'e' || tag[0] === 'p') + ])); unsigned.tags.push(['e', refEvent.id]); - } else { - if (tagType === 'Quote') { + }; + + switch (tagType) { + case 'Reply': + addEventTags(); + break; + case 'Quote': setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id)); unsigned.tags.push(['q', refEvent.id]); - } else { - unsigned.tags.push(['e', refEvent.id]); - } + break; + default: + addEventTags(); + break; } } diff --git a/client/src/components/routes/Thread.tsx b/client/src/components/routes/Thread.tsx index b8e08eb..10e96ff 100644 --- a/client/src/components/routes/Thread.tsx +++ b/client/src/components/routes/Thread.tsx @@ -22,7 +22,8 @@ const Thread = () => { const allEvents = [...noteEvents, ...threadCache]; const repliedList = (event: Event): Event[] => { - return allEvents.filter(e => event.tags.some(tag => tag[0] === 'p' && tag[1] === e.pubkey)); + return allEvents + .filter(e => event.tags.some(tag => tag[0] === 'p' && tag[1] === e.pubkey)) } // Define your callback function for subGlobalFeed @@ -64,16 +65,18 @@ const Thread = () => { e.pubkey === OPEvent.pubkey && e.kind === 0) || null} replies={replyEvents} type={'OP'}/> -
{/* This is the white line separator */} -
- {replyEvents.map((event, index) => ( +
{/* This is the white line separator */} +
+ {replyEvents.map((event: Event) => ( +
tag[0] === 'e' && tag[1] !== OPEvent.id) ? 'ml-auto' : 'mr-auto'}`}> e.pubkey === event.pubkey && e.kind === 0) || null} replies={replyEvents.filter((e: Event) => e.tags.some((tag) => tag[0] === "e" && tag[1] === event.id))} repliedTo={repliedList(event)} /> +
))}