feat: long form rendering

This commit is contained in:
2023-10-11 11:44:53 +01:00
parent 3b505f6c3e
commit 6eca5a632d
25 changed files with 508 additions and 191 deletions

View File

@ -105,7 +105,6 @@ export abstract class EventExt {
}
static extractThread(ev: NostrEvent) {
const shouldWriteMarkers = ev.kind === EventKind.TextNote;
const ret = {
mentions: [],
pubKeys: [],
@ -115,16 +114,14 @@ export abstract class EventExt {
const marked = replyTags.some(a => a.marker);
if (!marked) {
ret.root = replyTags[0];
ret.root.marker = shouldWriteMarkers ? "root" : undefined;
ret.root.marker = "root";
if (replyTags.length > 1) {
ret.replyTo = replyTags[replyTags.length - 1];
ret.replyTo.marker = shouldWriteMarkers ? "reply" : undefined;
ret.replyTo.marker = "reply";
}
if (replyTags.length > 2) {
ret.mentions = replyTags.slice(1, -1);
if (shouldWriteMarkers) {
ret.mentions.forEach(a => (a.marker = "mention"));
}
ret.mentions.forEach(a => (a.marker = "mention"));
}
} else {
const root = replyTags.find(a => a.marker === "root");