feed: add reply to info

Add reply to event id and if available relay info. Relay info is
not always available, see positional e tags (DEPRECATED) NIP-10.
OFF0 2 years ago
parent 69afa63201
commit cab1d14603
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -62,17 +62,20 @@ const subscription = pool.sub({
} }
}); });
const hasEventTag = tag => tag[0] === 'e';
const getShortTagId = tag => `${tag[1].slice(0, 7)}${tag[2] ? '@' + tag[2] : ''}`;
function renderTextNote(evt, relay) { function renderTextNote(evt, relay) {
if (evt.tags.length) { if (evt.tags.length) {
console.log('has tags', evt) console.log('has tags', evt)
} }
const [host, img, time, userName] = getMetadata(evt, relay); const [host, img, time, userName] = getMetadata(evt, relay);
const isReply = evt.tags.some(hasEventTag);
const body = elem('div', {className: 'mbox-body', title: dateTime.format(time)}, [ const body = elem('div', {className: 'mbox-body', title: dateTime.format(time)}, [
renderProfile(userName, host), renderProfile(userName, host),
elem('div', {}, evt.id), elem('div', {}, isReply ? `reply to ${evt.tags.filter(hasEventTag).map(getShortTagId).join(' and ')}` : evt.id),
evt.content // text evt.content // text
]); ]);
const isReply = evt.tags.some(tag => tag[0] === 'e');
rendernArticle([img, body], isReply && {className: 'mbox-reply'}); rendernArticle([img, body], isReply && {className: 'mbox-reply'});
} }

Loading…
Cancel
Save