fix: remove broken timeline subscription, rely on queryEvents

- Timeline subscription is async and emits empty array first
- queryEvents already checks local store then relays
- Simpler and actually works correctly
- This is how all other controllers work (highlights, bookmarks, etc.)
This commit is contained in:
Gigi
2025-10-19 12:17:38 +02:00
parent 16b3668e73
commit 4fac5f42c9

View File

@@ -129,31 +129,8 @@ class ReadingProgressController {
this.lastLoadedPubkey = pubkey
try {
// 1. First, get events from local event store timeline (instant, non-blocking)
const timeline = eventStore.timeline({
kinds: [KINDS.ReadingProgress],
authors: [pubkey]
})
// Get the latest value from timeline - it should emit immediately
let localEvents: any[] = []
const subscription = timeline.subscribe((events) => {
localEvents = events
console.log('📊 [ReadingProgress] Timeline emitted', events.length, 'events')
})
// Unsubscribe after getting value
subscription.unsubscribe()
console.log('📊 [ReadingProgress] Processing', localEvents.length, 'events from local store')
console.log('📊 [ReadingProgress] Sample event:', localEvents[0] ? { kind: localEvents[0].kind, author: localEvents[0].pubkey?.slice(0, 8), tags: localEvents[0].tags } : 'none')
if (localEvents.length > 0) {
this.processEvents(localEvents)
console.log('📊 [ReadingProgress] After processEvents, map size:', this.currentProgressMap.size)
}
// 2. Then fetch from relays (incremental or full) to augment local data
// Query events - this checks both local store AND relays
// The queryEvents function is smart enough to check local first
const lastSynced = force ? null : this.getLastSyncedAt(pubkey)
const filter: any = {
kinds: [KINDS.ReadingProgress],