Fix some tag utilities, re-work content rendering

This commit is contained in:
Jon Staab
2024-12-05 15:30:39 -08:00
parent d450f532ea
commit 7982bebb35
5 changed files with 99 additions and 65 deletions
+4 -4
View File
@@ -63,23 +63,23 @@ export const removeFromListByPredicate = (list: List, pred: (t: string[]) => boo
export const removeFromList = (list: List, value: string) =>
removeFromListByPredicate(list, nthEq(1, value))
export const addToListPublicly = (list: List, tag: string[]) => {
export const addToListPublicly = (list: List, ...tags: string[][]) => {
const template = {
kind: list.kind,
content: list.event?.content || "",
tags: uniqTags(append(tag, list.publicTags)),
tags: uniqTags([...list.publicTags, ...tags]),
}
return new Encryptable(template, {})
}
export const addToListPrivately = (list: List, tag: string[]) => {
export const addToListPrivately = (list: List, ...tags: string[][]) => {
const template = {
kind: list.kind,
tags: list.publicTags,
}
return new Encryptable(template, {
content: JSON.stringify(uniqTags(append(tag, list.privateTags))),
content: JSON.stringify(uniqTags([...list.privateTags, ...tags])),
})
}
+2 -2
View File
@@ -194,12 +194,12 @@ export const getTopicTags = (tags: string[][]) => tags.filter(t => ["t"].include
export const getTopicTagValues = (tags: string[][]) => getTopicTags(tags).map(nth(1))
export const getRelayTags = (tags: string[][]) =>
tags.filter(t => ["r", "relay"].includes(t[0]) && isRelayUrl(t[1]))
tags.filter(t => ["r", "relay"].includes(t[0]) && isRelayUrl(t[1] || ""))
export const getRelayTagValues = (tags: string[][]) => getRelayTags(tags).map(nth(1))
export const getGroupTags = (tags: string[][]) =>
tags.filter(t => ["h", "group"].includes(t[0]) && t[1] && isRelayUrl(t[2]))
tags.filter(t => ["h", "group"].includes(t[0]) && t[1] && isRelayUrl(t[2] || ""))
export const getGroupTagValues = (tags: string[][]) => getGroupTags(tags).map(nth(1))