fix: attempt to fix issue of no parent reply
This commit is contained in:
@@ -60,7 +60,7 @@ export async function createShortTextNoteDraftEvent(
|
|||||||
const tags = pubkeys
|
const tags = pubkeys
|
||||||
.map((pubkey) => ['p', pubkey])
|
.map((pubkey) => ['p', pubkey])
|
||||||
.concat(otherRelatedEventIds.map((eventId) => ['e', eventId]))
|
.concat(otherRelatedEventIds.map((eventId) => ['e', eventId]))
|
||||||
.concat(quoteEventIds.map((eventId) => ['q', eventId]))
|
.concat(quoteEventIds.map((eventId) => ['q', eventId, '', 'mention']))
|
||||||
.concat(hashtags.map((hashtag) => ['t', hashtag]))
|
.concat(hashtags.map((hashtag) => ['t', hashtag]))
|
||||||
|
|
||||||
if (rootEventId) {
|
if (rootEventId) {
|
||||||
|
|||||||
@@ -17,17 +17,20 @@ export function isReplyNoteEvent(event: Event) {
|
|||||||
if (event.kind !== kinds.ShortTextNote) return false
|
if (event.kind !== kinds.ShortTextNote) return false
|
||||||
|
|
||||||
let hasETag = false
|
let hasETag = false
|
||||||
let hasMarker = false
|
let hasMentionMarker = false
|
||||||
for (const [tagName, , , marker] of event.tags) {
|
for (const [tagName, , , marker] of event.tags) {
|
||||||
if (tagName !== 'e') continue
|
if (tagName !== 'e') continue
|
||||||
hasETag = true
|
hasETag = true
|
||||||
|
|
||||||
if (!marker) continue
|
if (!marker) continue
|
||||||
hasMarker = true
|
if (marker === 'mention') {
|
||||||
|
hasMentionMarker = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if (['root', 'reply'].includes(marker)) return true
|
if (['root', 'reply'].includes(marker)) return true
|
||||||
}
|
}
|
||||||
return hasETag && !hasMarker
|
return hasETag && !hasMentionMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCommentEvent(event: Event) {
|
export function isCommentEvent(event: Event) {
|
||||||
@@ -39,11 +42,13 @@ export function isPictureEvent(event: Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getParentEventId(event?: Event) {
|
export function getParentEventId(event?: Event) {
|
||||||
return event?.tags.find(isReplyETag)?.[1]
|
if (!event || !isReplyNoteEvent(event)) return undefined
|
||||||
|
return event.tags.find(isReplyETag)?.[1] ?? event.tags.find(tagNameEquals('e'))?.[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRootEventId(event?: Event) {
|
export function getRootEventId(event?: Event) {
|
||||||
return event?.tags.find(isRootETag)?.[1]
|
if (!event || !isReplyNoteEvent(event)) return undefined
|
||||||
|
return event.tags.find(isRootETag)?.[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isReplaceable(kind: number) {
|
export function isReplaceable(kind: number) {
|
||||||
|
|||||||
Reference in New Issue
Block a user