Add some kinds, fix tag ancestors to work with positional e and a tags
This commit is contained in:
@@ -25,6 +25,7 @@ export const OPEN_TIMESTAMP = 1040
|
||||
export const GIFT_WRAP = 1059
|
||||
export const FILE_METADATA = 1063
|
||||
export const LIVE_CHAT_MESSAGE = 1311
|
||||
export const REMIX = 1808
|
||||
export const PROBLEM_TRACKER = 1971
|
||||
export const REPORT = 1984
|
||||
export const LABEL = 1985
|
||||
@@ -70,6 +71,7 @@ export const LIVE_EVENT = 30311
|
||||
export const USER_STATUSES = 30315
|
||||
export const CLASSIFIED_LISTING = 30402
|
||||
export const DRAFT_CLASSIFIED_LISTING = 30403
|
||||
export const AUDIO = 31337
|
||||
export const CALENDAR = 31924
|
||||
export const CALENDAR_EVENT_DATE = 31922
|
||||
export const CALENDAR_EVENT_TIME = 31923
|
||||
|
||||
@@ -224,13 +224,13 @@ export class Router {
|
||||
tagPubkey = (pubkey: string) =>
|
||||
Tag.from(["p", pubkey, this.FromPubkeys([pubkey]).getUrl()])
|
||||
|
||||
tagEventId = (event: Rumor, mark: string) =>
|
||||
tagEventId = (event: Rumor, mark = "") =>
|
||||
Tag.from(["e", event.id, this.Event(event).getUrl(), mark, event.pubkey])
|
||||
|
||||
tagEventAddress = (event: Rumor, mark: string) =>
|
||||
tagEventAddress = (event: Rumor, mark = "") =>
|
||||
Tag.from(["a", getAddress(event), this.Event(event).getUrl(), mark, event.pubkey])
|
||||
|
||||
tagEvent = (event: Rumor, mark: string) => {
|
||||
tagEvent = (event: Rumor, mark = "") => {
|
||||
const tags = [this.tagEventId(event, mark)]
|
||||
|
||||
if (isReplaceable(event)) {
|
||||
|
||||
@@ -90,21 +90,20 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
|
||||
ancestors = (x?: boolean) => {
|
||||
const tags = this.filterByKey(["a", "e", "q"]).reject(t => t.isContext())
|
||||
const parentTags = tags.filterByKey(["a", "e"])
|
||||
const mentionTags = tags.whereKey("q")
|
||||
const roots: string[][] = []
|
||||
const replies: string[][] = []
|
||||
const mentions: string[][] = []
|
||||
|
||||
parentTags
|
||||
.forEach((t: Tag, i: number) => {
|
||||
const dispatchTags = (thisTags: Tags) =>
|
||||
thisTags.forEach((t: Tag, i: number) => {
|
||||
if (t.mark() === 'root') {
|
||||
roots.push(t.valueOf())
|
||||
} else if (t.mark() === 'reply') {
|
||||
replies.push(t.valueOf())
|
||||
} else if (t.mark() === 'mention') {
|
||||
mentions.push(t.valueOf())
|
||||
} else if (i === parentTags.count() - 1) {
|
||||
} else if (i === thisTags.count() - 1) {
|
||||
replies.push(t.valueOf())
|
||||
} else if (i === 0) {
|
||||
roots.push(t.valueOf())
|
||||
@@ -113,7 +112,9 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
}
|
||||
})
|
||||
|
||||
// Add quotes as mentions separately so positional logic above works
|
||||
// Add different types separately so positional logic works
|
||||
dispatchTags(tags.whereKey("e"))
|
||||
dispatchTags(tags.whereKey("a"))
|
||||
mentionTags.forEach((t: Tag) => mentions.push(t.valueOf()))
|
||||
|
||||
return {
|
||||
@@ -144,7 +145,7 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
||||
parents = () => {
|
||||
const {roots, replies} = this.ancestors()
|
||||
|
||||
return replies.exists() ? replies: roots
|
||||
return replies.exists() ? replies : roots
|
||||
}
|
||||
|
||||
parent = () => {
|
||||
|
||||
Reference in New Issue
Block a user