From a0ebb99cf9a9c5a8ab20bec30f29bdf7ccd25ecb Mon Sep 17 00:00:00 2001 From: smolgrrr Date: Fri, 15 Dec 2023 22:05:57 +1100 Subject: [PATCH 1/3] fix reposts --- client/src/components/Home.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/components/Home.tsx b/client/src/components/Home.tsx index 188bc04..7c7eda0 100644 --- a/client/src/components/Home.tsx +++ b/client/src/components/Home.tsx @@ -21,7 +21,12 @@ const useUniqEvents = () => { const uniqEvents = uniqBy(events, "id"); - const noteEvents = uniqEvents.filter(event => event.kind === 1); + const noteEvents = uniqEvents.filter(event => { + if (event.kind === 6) { + console.log(event); + } + return event.kind === 1 || event.kind === 6; + }); const metadataEvents = uniqEvents.filter(event => event.kind === 0); return { noteEvents, metadataEvents }; From 88fefc8a1bb8a1cda47eb2a5ad54ebcb39c74018 Mon Sep 17 00:00:00 2001 From: smolgrrr Date: Fri, 15 Dec 2023 22:33:46 +1100 Subject: [PATCH 2/3] fix replies --- client/src/components/Forms/PostFormCard.tsx | 11 +++++++---- client/src/components/Home.tsx | 7 +------ client/src/components/Thread.tsx | 9 +++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/client/src/components/Forms/PostFormCard.tsx b/client/src/components/Forms/PostFormCard.tsx index e978d83..73a847a 100644 --- a/client/src/components/Forms/PostFormCard.tsx +++ b/client/src/components/Forms/PostFormCard.tsx @@ -45,10 +45,13 @@ const NewNoteCard = ({ useEffect(() => { if (refEvent && tagType && unsigned.tags.length === 0) { - const tags = tagMapping[tagType]; - if (tags) { - tags.forEach(tag => unsigned.tags.push([tag, refEvent[tag === 'p' ? 'pubkey' : 'id']])); - // Ref event should be the latest event they're replying to, and their event should include prev replies + if (tagType === 'Reply' && unsigned.tags.length === 0) { + unsigned.tags.push(['p', refEvent.pubkey]); + unsigned.tags.push(['e', refEvent.id, 'root']); + } else { + unsigned.tags = refEvent.tags + unsigned.tags.push(['p', refEvent.pubkey]); + unsigned.tags.push(['e', refEvent.id]); } if (tagType === 'Quote') { setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id)); diff --git a/client/src/components/Home.tsx b/client/src/components/Home.tsx index 7c7eda0..c74e287 100644 --- a/client/src/components/Home.tsx +++ b/client/src/components/Home.tsx @@ -21,12 +21,7 @@ const useUniqEvents = () => { const uniqEvents = uniqBy(events, "id"); - const noteEvents = uniqEvents.filter(event => { - if (event.kind === 6) { - console.log(event); - } - return event.kind === 1 || event.kind === 6; - }); + const noteEvents = uniqEvents.filter(event => event.kind === 1 || event.kind === 6); const metadataEvents = uniqEvents.filter(event => event.kind === 0); return { noteEvents, metadataEvents }; diff --git a/client/src/components/Thread.tsx b/client/src/components/Thread.tsx index d4d17fa..15bf075 100644 --- a/client/src/components/Thread.tsx +++ b/client/src/components/Thread.tsx @@ -49,9 +49,10 @@ const Thread = () => { useEffect(() => { if (!hasRun && events.length > 0) { - let OPEvent = uniqEvents[0]; + let OPEvent = uniqEvents.find(event => event.id === hexID); setOPEvent(OPEvent); + console.log(OPEvent) if (OPEvent && OPEvent.id !== hexID) { OPEvent = events.find(e => e.id === hexID) as Event; } @@ -154,11 +155,11 @@ const Thread = () => { {(showForm && postType) &&
{postType}-post - +
} - {showRepost &&
+ {showRepost && OPEvent &&
Repost note - +
}