mirror of
https://github.com/dergigi/boris.git
synced 2025-12-19 07:34:28 +01:00
chore(debug): add [archive] debug logs in archiveController, Me, and ContentPanel to trace archive filter behavior
This commit is contained in:
@@ -573,6 +573,7 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
try {
|
||||
const naddr = nip19.naddrEncode({ kind: 30023, pubkey: currentArticle.pubkey, identifier: dTag })
|
||||
hasRead = hasRead || archiveController.isMarked(naddr)
|
||||
console.log('[archive][content] check article', { naddr: naddr.slice(0, 24) + '...', hasRead })
|
||||
} catch {}
|
||||
}
|
||||
} else {
|
||||
@@ -582,7 +583,9 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
relayPool
|
||||
)
|
||||
// Also check archiveController
|
||||
hasRead = hasRead || archiveController.isMarked(selectedUrl)
|
||||
const ctrl = archiveController.isMarked(selectedUrl)
|
||||
hasRead = hasRead || ctrl
|
||||
console.log('[archive][content] check url', { url: selectedUrl, hasRead, ctrl })
|
||||
}
|
||||
setIsMarkedAsRead(hasRead)
|
||||
} catch (error) {
|
||||
@@ -628,6 +631,7 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore private update for instant UI; controller will confirm via stream
|
||||
archiveController['markedIds'].add(naddr)
|
||||
console.log('[archive][content] optimistic mark article', naddr.slice(0, 24) + '...')
|
||||
}
|
||||
} catch {}
|
||||
} else if (selectedUrl) {
|
||||
@@ -639,6 +643,7 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore private update for instant UI; controller will confirm via stream
|
||||
archiveController['markedIds'].add(selectedUrl)
|
||||
console.log('[archive][content] optimistic mark url', selectedUrl)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to mark as read:', error)
|
||||
|
||||
@@ -632,6 +632,19 @@ const Me: React.FC<MeProps> = ({
|
||||
readingProgressFilter,
|
||||
highlights
|
||||
)
|
||||
|
||||
// Debug logs for archive filter issues
|
||||
if (readingProgressFilter === 'archive') {
|
||||
console.log('[archive][me] counts', {
|
||||
reads: reads.length,
|
||||
readsWithProgress: readsWithProgress.length,
|
||||
filteredReads: filteredReads.length,
|
||||
links: links.length,
|
||||
linksWithProgress: linksWithProgress.length,
|
||||
filteredLinks: filteredLinks.length,
|
||||
markedIds: archiveController.getMarkedIds().length
|
||||
})
|
||||
}
|
||||
const sections: Array<{ key: string; title: string; items: IndividualBookmark[] }> =
|
||||
groupingMode === 'flat'
|
||||
? [{ key: 'all', title: `All Bookmarks (${filteredBookmarks.length})`, items: filteredBookmarks }]
|
||||
|
||||
@@ -58,11 +58,13 @@ class ArchiveController {
|
||||
const startGen = this.generation
|
||||
|
||||
if (!force && this.isLoadedFor(pubkey)) {
|
||||
console.log('[archive] start() skipped - already loaded for pubkey')
|
||||
return
|
||||
}
|
||||
|
||||
// Mark as loaded immediately (fetch runs non-blocking)
|
||||
this.lastLoadedPubkey = pubkey
|
||||
console.log('[archive] start() begin for pubkey:', pubkey.slice(0, 12), '...')
|
||||
|
||||
const seenIds = new Set<string>()
|
||||
|
||||
@@ -73,6 +75,7 @@ class ArchiveController {
|
||||
if (!rTag) return
|
||||
this.markedIds.add(rTag)
|
||||
this.emit()
|
||||
console.log('[archive] mark url:', rTag)
|
||||
}
|
||||
|
||||
const pendingEventIds = new Set<string>()
|
||||
@@ -81,6 +84,7 @@ class ArchiveController {
|
||||
const eTag = evt.tags.find(t => t[0] === 'e')?.[1]
|
||||
if (!eTag) return
|
||||
pendingEventIds.add(eTag)
|
||||
console.log('[archive] pending event id:', eTag)
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -95,25 +99,30 @@ class ArchiveController {
|
||||
// Include EOSE events
|
||||
kind17.forEach(handleUrlReaction)
|
||||
kind7.forEach(handleEventReaction)
|
||||
console.log('[archive] EOSE sizes kind17:', kind17.length, 'kind7:', kind7.length, 'pendingEventIds:', pendingEventIds.size)
|
||||
|
||||
if (pendingEventIds.size > 0) {
|
||||
// Fetch referenced articles (kind:30023) and map event IDs to naddr
|
||||
const ids = Array.from(pendingEventIds)
|
||||
const articleEvents = await queryEvents(relayPool, { kinds: [KINDS.BlogPost], ids }, { relayUrls: RELAYS })
|
||||
console.log('[archive] fetched articles for mapping:', articleEvents.length)
|
||||
for (const article of articleEvents) {
|
||||
const dTag = article.tags.find(t => t[0] === 'd')?.[1]
|
||||
if (!dTag) continue
|
||||
try {
|
||||
const naddr = nip19.naddrEncode({ kind: KINDS.BlogPost, pubkey: article.pubkey, identifier: dTag })
|
||||
this.markedIds.add(naddr)
|
||||
console.log('[archive] mark naddr:', naddr.slice(0, 24), '...')
|
||||
} catch {
|
||||
// skip invalid
|
||||
}
|
||||
}
|
||||
this.emit()
|
||||
}
|
||||
console.log('[archive] total marked ids:', this.markedIds.size)
|
||||
} catch (err) {
|
||||
// Non-blocking fetch; ignore errors here
|
||||
console.warn('[archive] start() error:', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user