Fix some tag utilities, re-work content rendering
This commit is contained in:
@@ -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])),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user