Make tags more unique

This commit is contained in:
Jon Staab
2025-01-28 13:19:01 -08:00
parent ac3408c119
commit d0c6d5245b
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import {ctx, remove, nthEq} from "@welshman/lib" import {ctx, uniq, remove, nthEq} from "@welshman/lib"
import { import {
getAddress, getAddress,
isReplaceable, isReplaceable,
@@ -36,7 +36,7 @@ export const tagEvent = (event: TrustedEvent, mark = "") => {
} }
export const tagEventPubkeys = (event: TrustedEvent) => export const tagEventPubkeys = (event: TrustedEvent) =>
remove(pubkey.get()!, [event.pubkey, ...getPubkeyTagValues(event.tags)]).map(tagPubkey) uniq(remove(pubkey.get()!, [event.pubkey, ...getPubkeyTagValues(event.tags)])).map(tagPubkey)
export const tagEventForQuote = (event: TrustedEvent) => [ export const tagEventForQuote = (event: TrustedEvent) => [
"q", "q",
+1 -1
View File
@@ -103,6 +103,6 @@ export const getReplyTags = (tags: string[][]) => {
export const getReplyTagValues = (tags: string[][]) => export const getReplyTagValues = (tags: string[][]) =>
mapVals(tags => tags.map(nth(1)), getReplyTags(tags)) mapVals(tags => tags.map(nth(1)), getReplyTags(tags))
export const uniqTags = (tags: string[][]) => uniqBy(t => t.join(":"), tags) export const uniqTags = (tags: string[][]) => uniqBy(t => t.slice(0, 2).join(":"), tags)
export const tagsFromIMeta = (imeta: string[]) => imeta.map((m: string) => m.split(" ")) export const tagsFromIMeta = (imeta: string[]) => imeta.map((m: string) => m.split(" "))