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.
OFF0 2 years ago
parent dbb4970256
commit f8bb537160
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -484,7 +484,7 @@ function handleReply(evt, relay) {
} }
function renderReply(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]; const article = feedDomMap[eventId] || replyDomMap[eventId];
if (!article) { // root article has not been rendered if (!article) { // root article has not been rendered
return; return;
@ -687,7 +687,7 @@ function getMetadata(evt, relay) {
title: `${userName} on ${host} ${userAbout}`, title: `${userName} on ${host} ${userAbout}`,
}) : elemCanvas(evt.pubkey); }) : elemCanvas(evt.pubkey);
const isReply = evt.tags.some(hasEventTag); 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); const time = new Date(evt.created_at * 1000);
return {host, img, isReply, name, replies, time, userName}; return {host, img, isReply, name, replies, time, userName};
} }

Loading…
Cancel
Save