Fix tag normalize and reply tag construction

This commit is contained in:
Jon Staab 2023-11-10 22:50:44 -08:00
parent ec543b74c7
commit b4400627c7
3 changed files with 6 additions and 7 deletions

View File

@ -58,7 +58,7 @@
"normalize-url": "^8.0.0",
"nostr-tools": "^1.12.1",
"npm-run-all": "^4.1.5",
"paravel": "^0.4.1",
"paravel": "^0.4.3",
"qr-scanner": "^1.4.2",
"qrcode": "^1.5.1",
"ramda": "^0.28.0",

View File

@ -1,6 +1,6 @@
import EventEmitter from "events"
import {createEvent, Tags} from "paravel"
import {omit, uniqBy} from "ramda"
import {omit, uniqBy, nth} from "ramda"
import {defer, union, difference} from "hurdak"
import {info} from "src/util/logger"
import {parseContent} from "src/util/notes"
@ -180,13 +180,12 @@ export const tagsFromContent = (content: string) => {
export const getReplyTags = (parent: Event, inherit = false) => {
const hint = getEventHint(parent)
const tags = Tags.from(parent).normalize()
const reply = tags.mark("reply").first() || ["e", parent.id, hint, "reply"]
const root = tags.mark("root").first() || reply.slice(0, 3).concat("root")
const reply = ["e", parent.id, hint, "reply"]
const root = tags.mark("root").first() || reply.slice(0, 3).concat('root')
const extra = inherit
? tags
.type(["a", "e"])
.reject(t => [reply[1], root[1]].includes(t[1]))
.take(3)
.map(t => t.slice(0, 3).concat('mention'))
.all()
: []
@ -194,5 +193,5 @@ export const getReplyTags = (parent: Event, inherit = false) => {
extra.push(Naddr.fromEvent(parent).asTag("reply"))
}
return [mention(parent.pubkey), root, ...extra, reply]
return uniqBy(nth(1), [mention(parent.pubkey), root, ...extra, reply])
}

BIN
yarn.lock

Binary file not shown.