mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-29 08:21:20 +00:00
Only tag parent event in reactions
This commit is contained in:
parent
099dbb39b4
commit
e4fe5a4661
@ -26,6 +26,7 @@
|
||||
- [x] Re-work utility library
|
||||
- [x] Make buttons, chips, and inputs sleeker
|
||||
- [x] Clean up onboarding with an invite
|
||||
- [x] Only tag parent event in reactions
|
||||
|
||||
# 0.4.4
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
getSetting,
|
||||
loadPubkeys,
|
||||
isEventMuted,
|
||||
getReplyTags,
|
||||
getReactionTags,
|
||||
getClientTags,
|
||||
} from "src/engine"
|
||||
import {getHandlerKey} from "src/domain"
|
||||
@ -108,7 +108,7 @@
|
||||
tags.context().values().valueOf(),
|
||||
createEvent(7, {
|
||||
content,
|
||||
tags: [...getReplyTags(note), ...getClientTags()],
|
||||
tags: [...getReactionTags(note), ...getClientTags()],
|
||||
}),
|
||||
)
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
const tags = [...tagsFromContent(content), ...getClientTags()]
|
||||
|
||||
if (parent) {
|
||||
for (const tag of getReplyTags(parent, true)) {
|
||||
for (const tag of getReplyTags(parent)) {
|
||||
tags.push(tag)
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@
|
||||
|
||||
const tags = uniqTags([
|
||||
...mentions.map(mention),
|
||||
...getReplyTags(parent, true),
|
||||
...getReplyTags(parent),
|
||||
...tagsFromContent(content),
|
||||
...getClientTags(),
|
||||
])
|
||||
|
@ -1703,7 +1703,7 @@ export const tagsFromContent = (content: string) => {
|
||||
return tags
|
||||
}
|
||||
|
||||
export const getReplyTags = (parent: TrustedEvent, inherit = false) => {
|
||||
export const getReplyTags = (parent: TrustedEvent) => {
|
||||
const tags = Tags.fromEvent(parent)
|
||||
const replyTagValues = getIdAndAddress(parent)
|
||||
const userPubkey = pubkey.get()
|
||||
@ -1715,11 +1715,9 @@ export const getReplyTags = (parent: TrustedEvent, inherit = false) => {
|
||||
}
|
||||
|
||||
// Inherit p-tag mentions
|
||||
if (inherit) {
|
||||
for (const pubkey of tags.values("p").valueOf()) {
|
||||
if (pubkey !== userPubkey) {
|
||||
replyTags.push(mention(pubkey))
|
||||
}
|
||||
for (const pubkey of tags.values("p").valueOf()) {
|
||||
if (pubkey !== userPubkey) {
|
||||
replyTags.push(mention(pubkey))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1737,25 +1735,23 @@ export const getReplyTags = (parent: TrustedEvent, inherit = false) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (inherit) {
|
||||
// Make sure we don't repeat any tag values
|
||||
const isRepeated = v => replyTagValues.includes(v) || replyTags.find(t => t[1] === v)
|
||||
// Make sure we don't repeat any tag values
|
||||
const isRepeated = v => replyTagValues.includes(v) || replyTags.find(t => t[1] === v)
|
||||
|
||||
// Inherit mentions
|
||||
for (const t of mentions.valueOf()) {
|
||||
// Inherit mentions
|
||||
for (const t of mentions.valueOf()) {
|
||||
if (!isRepeated(t.value())) {
|
||||
replyTags.push(t.set(3, "mention").valueOf())
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit replies if they weren't already included
|
||||
if (roots.exists()) {
|
||||
for (const t of replies.valueOf()) {
|
||||
if (!isRepeated(t.value())) {
|
||||
replyTags.push(t.set(3, "mention").valueOf())
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit replies if they weren't already included
|
||||
if (roots.exists()) {
|
||||
for (const t of replies.valueOf()) {
|
||||
if (!isRepeated(t.value())) {
|
||||
replyTags.push(t.set(3, "mention").valueOf())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a/e-tags for the parent event
|
||||
@ -1767,6 +1763,22 @@ export const getReplyTags = (parent: TrustedEvent, inherit = false) => {
|
||||
return replyTags
|
||||
}
|
||||
|
||||
export const getReactionTags = (parent: TrustedEvent) => {
|
||||
const replyTags = []
|
||||
|
||||
// Mention the parent's author
|
||||
if (parent.pubkey !== pubkey.get()) {
|
||||
replyTags.push(mention(parent.pubkey))
|
||||
}
|
||||
|
||||
// Add a/e-tags for the parent event
|
||||
for (const t of hints.tagEvent(parent, "root").valueOf()) {
|
||||
replyTags.push(t.valueOf())
|
||||
}
|
||||
|
||||
return replyTags
|
||||
}
|
||||
|
||||
export const getClientTags = () => {
|
||||
if (!getSetting("enable_client_tag")) {
|
||||
return []
|
||||
|
Loading…
Reference in New Issue
Block a user