From f8bb537160db7469e14b25691fde9ab62564f22f Mon Sep 17 00:00:00 2001 From: OFF0 Date: Wed, 4 Jan 2023 10:41:23 +0100 Subject: [PATCH] feed: dirty fix to show replies now that nonce tag is always the first element in the tags list, a bug surfaced that replies from nostrweb did not render anymore. reason was that the code expected the first tag to be an e tag and took its reply-id. this commit is a quick fix that takes the first reply-id fromt the first e tag. the proper way is a bit more complicated as nip-10 defines a preferred and deprecated way. this is a quick and dirty fix so that replies work with nip-13 pow events, but nip-10 event tags should be properly supported but in a later commit. --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index a7b0458..ad641c0 100644 --- a/src/main.js +++ b/src/main.js @@ -484,7 +484,7 @@ function handleReply(evt, relay) { } function renderReply(evt, relay) { - const eventId = evt.tags[0][1]; // TODO: double check + const eventId = evt.tags.filter(hasEventTag)[0][1]; // TODO: should check for 'reply' marker with fallback to 'root' marker or last 'e' tag, see nip-10 const article = feedDomMap[eventId] || replyDomMap[eventId]; if (!article) { // root article has not been rendered return; @@ -687,7 +687,7 @@ function getMetadata(evt, relay) { title: `${userName} on ${host} ${userAbout}`, }) : elemCanvas(evt.pubkey); const isReply = evt.tags.some(hasEventTag); - const replies = replyList.filter((reply) => reply.tags[0][1] === evt.id); + const replies = replyList.filter(({tags}) => tags.filter(hasEventTag).some(reply => reply[1] === evt.id)); // TODO: nip-10 const time = new Date(evt.created_at * 1000); return {host, img, isReply, name, replies, time, userName}; }