mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Fix reply/root
This commit is contained in:
parent
52bad3ac7b
commit
6ac4df7ee9
@ -1,6 +1,7 @@
|
||||
# Current
|
||||
|
||||
- [ ] Add threads - replies by self get shown at the top of replies?
|
||||
- [ ] Fix rich text -> plain text using library
|
||||
- [ ] Highlights
|
||||
- Allow highlighting text in notes
|
||||
- When something is highlighted, show fixed-position elements for adding highlights
|
||||
|
@ -76,7 +76,7 @@ const createReply = (note, content, mentions = [], topics = []) => {
|
||||
[
|
||||
tags => tags.concat(processMentions(mentions)),
|
||||
tags => tags.concat(topics.map(t => ["t", t])),
|
||||
tags => tags.concat(getReplyTags(note)),
|
||||
tags => tags.concat(getReplyTags(note, true)),
|
||||
tags => tagsFromContent(content, tags),
|
||||
uniqTags,
|
||||
]
|
||||
@ -132,7 +132,13 @@ const tagsFromContent = (content, tags) => {
|
||||
return tags
|
||||
}
|
||||
|
||||
const getReplyTags = n => {
|
||||
const getReplyTags = (n, inherit = false) => {
|
||||
const extra = inherit
|
||||
? Tags.from(n)
|
||||
.type("e")
|
||||
.all()
|
||||
.map(t => t.slice(0, 3))
|
||||
: []
|
||||
const pHint = getRelayForPersonHint(n.pubkey)
|
||||
const eHint = getRelayForEventHint(n) || pHint
|
||||
const reply = ["e", n.id, eHint?.url || "", "reply"]
|
||||
@ -141,7 +147,7 @@ const getReplyTags = n => {
|
||||
t => t.slice(0, 3).concat("root"),
|
||||
])
|
||||
|
||||
return [["p", n.pubkey, pHint?.url || ""], root, reply]
|
||||
return [["p", n.pubkey, pHint?.url || ""], root, ...extra, reply]
|
||||
}
|
||||
|
||||
const uniqTags = uniqBy(t => t.slice(0, 2).join(":"))
|
||||
|
@ -88,10 +88,10 @@ export const findReplyAndRoot = e => {
|
||||
return {reply, root}
|
||||
}
|
||||
|
||||
return {
|
||||
reply: tags.mark("reply").first(),
|
||||
root: tags.mark("root").first(),
|
||||
}
|
||||
const reply = tags.mark("reply").first()
|
||||
const root = tags.mark("root").first()
|
||||
|
||||
return {reply: reply || root, root}
|
||||
}
|
||||
|
||||
export const findReply = e => prop("reply", findReplyAndRoot(e))
|
||||
|
Loading…
Reference in New Issue
Block a user