mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-29 08:21:20 +00:00
Fix tag normalize and reply tag construction
This commit is contained in:
parent
ec543b74c7
commit
b4400627c7
@ -58,7 +58,7 @@
|
|||||||
"normalize-url": "^8.0.0",
|
"normalize-url": "^8.0.0",
|
||||||
"nostr-tools": "^1.12.1",
|
"nostr-tools": "^1.12.1",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"paravel": "^0.4.1",
|
"paravel": "^0.4.3",
|
||||||
"qr-scanner": "^1.4.2",
|
"qr-scanner": "^1.4.2",
|
||||||
"qrcode": "^1.5.1",
|
"qrcode": "^1.5.1",
|
||||||
"ramda": "^0.28.0",
|
"ramda": "^0.28.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import EventEmitter from "events"
|
import EventEmitter from "events"
|
||||||
import {createEvent, Tags} from "paravel"
|
import {createEvent, Tags} from "paravel"
|
||||||
import {omit, uniqBy} from "ramda"
|
import {omit, uniqBy, nth} from "ramda"
|
||||||
import {defer, union, difference} from "hurdak"
|
import {defer, union, difference} from "hurdak"
|
||||||
import {info} from "src/util/logger"
|
import {info} from "src/util/logger"
|
||||||
import {parseContent} from "src/util/notes"
|
import {parseContent} from "src/util/notes"
|
||||||
@ -180,13 +180,12 @@ export const tagsFromContent = (content: string) => {
|
|||||||
export const getReplyTags = (parent: Event, inherit = false) => {
|
export const getReplyTags = (parent: Event, inherit = false) => {
|
||||||
const hint = getEventHint(parent)
|
const hint = getEventHint(parent)
|
||||||
const tags = Tags.from(parent).normalize()
|
const tags = Tags.from(parent).normalize()
|
||||||
const reply = tags.mark("reply").first() || ["e", parent.id, hint, "reply"]
|
const reply = ["e", parent.id, hint, "reply"]
|
||||||
const root = tags.mark("root").first() || reply.slice(0, 3).concat("root")
|
const root = tags.mark("root").first() || reply.slice(0, 3).concat('root')
|
||||||
const extra = inherit
|
const extra = inherit
|
||||||
? tags
|
? tags
|
||||||
.type(["a", "e"])
|
.type(["a", "e"])
|
||||||
.reject(t => [reply[1], root[1]].includes(t[1]))
|
.map(t => t.slice(0, 3).concat('mention'))
|
||||||
.take(3)
|
|
||||||
.all()
|
.all()
|
||||||
: []
|
: []
|
||||||
|
|
||||||
@ -194,5 +193,5 @@ export const getReplyTags = (parent: Event, inherit = false) => {
|
|||||||
extra.push(Naddr.fromEvent(parent).asTag("reply"))
|
extra.push(Naddr.fromEvent(parent).asTag("reply"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return [mention(parent.pubkey), root, ...extra, reply]
|
return uniqBy(nth(1), [mention(parent.pubkey), root, ...extra, reply])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user