feed: sort replies by created at

replies were not sorted correctly, reason for this was that an
array of dom elements was sorted, but instead it should sort the
notes.

regression introduced in:
- 2e40a273c4
pull/68/head
OFF0 1 year ago
parent 0dcfa6e0a9
commit e94c9c92da
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -463,7 +463,7 @@ function createTextNote(evt, relay) {
// const content = isLongContent ? evt.content.slice(0, 280) : evt.content;
const hasReactions = reactionMap[evt.id]?.length > 0;
const didReact = hasReactions && !!reactionMap[evt.id].find(reaction => reaction.pubkey === pubkey);
const replyFeed = replies[0] ? replies.map(e => replyDomMap[e.id] = createTextNote(e, relay)) : [];
const replyFeed = replies[0] ? replies.sort(sortByCreatedAt).map(e => replyDomMap[e.id] = createTextNote(e, relay)) : [];
const [content, {firstLink}] = parseTextContent(evt.content);
const body = elem('div', {className: 'mbox-body'}, [
elem('header', {
@ -503,7 +503,7 @@ function createTextNote(evt, relay) {
}
return renderArticle([
elem('div', {className: 'mbox-img'}, [img]), body,
replies[0] ? elem('div', {className: 'mobx-replies'}, replyFeed.sort(sortByCreatedAt).reverse()) : '',
replies[0] ? elem('div', {className: 'mobx-replies'}, replyFeed.reverse()) : '',
], {data: {id: evt.id, pubkey: evt.pubkey, relay}});
}

Loading…
Cancel
Save