fix(archive): add 'a' coord tag to mark-as-read reactions for articles; archiveController maps a-tag instantly; add debug

This commit is contained in:
Gigi
2025-10-20 11:17:30 +02:00
parent c21f96f5bb
commit 8cde36c08c
4 changed files with 41 additions and 6 deletions

View File

@@ -621,7 +621,16 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
currentArticle.pubkey,
currentArticle.kind,
activeAccount,
relayPool
relayPool,
{
aCoord: (() => {
try {
const dTag = currentArticle.tags.find(t => t[0] === 'd')?.[1]
if (!dTag) return undefined
return `${30023}:${currentArticle.pubkey}:${dTag}`
} catch { return undefined }
})()
}
)
// Update archiveController immediately
try {

View File

@@ -635,6 +635,10 @@ const Me: React.FC<MeProps> = ({
// Debug logs for archive filter issues
if (readingProgressFilter === 'archive') {
const ids = archiveController.getMarkedIds()
const readIds = new Set(readsWithProgress.map(i => i.id))
const matches = ids.filter(id => readIds.has(id))
const nonMatches = ids.filter(id => !readIds.has(id)).slice(0, 5)
console.log('[archive][me] counts', {
reads: reads.length,
readsWithProgress: readsWithProgress.length,
@@ -642,8 +646,10 @@ const Me: React.FC<MeProps> = ({
links: links.length,
linksWithProgress: linksWithProgress.length,
filteredLinks: filteredLinks.length,
markedIds: archiveController.getMarkedIds().length,
sampleMarked: archiveController.getMarkedIds().slice(0, 3)
markedIds: ids.length,
sampleMarked: ids.slice(0, 3),
matches: matches.length,
nonMatches
})
}
const sections: Array<{ key: string; title: string; items: IndividualBookmark[] }> =

View File

@@ -85,6 +85,21 @@ class ArchiveController {
const handleEventReaction = (evt: NostrEvent) => {
if (evt.content !== MARK_AS_READ_EMOJI) return
// Direct coordinate tag ('a') - can be mapped immediately
const aTag = evt.tags.find(t => t[0] === 'a')?.[1]
if (aTag) {
try {
const [kindStr, pubkey, identifier] = aTag.split(':')
const kind = Number(kindStr)
if (kind === KINDS.BlogPost && pubkey && identifier) {
const naddr = nip19.naddrEncode({ kind, pubkey, identifier })
this.markedIds.add(naddr)
this.emit()
console.log('[archive] mark naddr via a-tag:', naddr.slice(0, 24), '...')
return
}
} catch { /* ignore malformed a-tag */ }
}
const eTag = evt.tags.find(t => t[0] === 'e')?.[1]
if (!eTag) return
this.pendingEventIds.add(eTag)
@@ -130,8 +145,8 @@ class ArchiveController {
const stillPending = new Set<string>()
for (const eId of this.pendingEventIds) {
try {
// @ts-expect-error eventStore may have getEvent
const evt: NostrEvent | undefined = (eventStore as unknown as { getEvent?: (id: string) => NostrEvent | undefined }).getEvent?.(eId)
const store = eventStore as unknown as { getEvent?: (id: string) => NostrEvent | undefined }
const evt: NostrEvent | undefined = typeof store.getEvent === 'function' ? store.getEvent(eId) : undefined
if (evt && evt.kind === KINDS.BlogPost) {
const dTag = evt.tags.find(t => t[0] === 'd')?.[1]
if (dTag) {

View File

@@ -23,7 +23,8 @@ export async function createEventReaction(
eventAuthor: string,
eventKind: number,
account: IAccount,
relayPool: RelayPool
relayPool: RelayPool,
options?: { aCoord?: string }
): Promise<NostrEvent> {
const factory = new EventFactory({ signer: account })
@@ -32,6 +33,10 @@ export async function createEventReaction(
['p', eventAuthor],
['k', eventKind.toString()]
]
if (options?.aCoord) {
tags.push(['a', options.aCoord])
console.log('[archive] createEventReaction add a-tag:', options.aCoord)
}
const draft = await factory.create(async () => ({
kind: 7, // Reaction