debug: improve timeline subscription and add more logs

- Capture events from timeline before unsubscribing
- Add log to show when timeline emits
- Add log after unsubscribe to show what we got
- This will help debug why processEvents isn't being called
This commit is contained in:
Gigi
2025-10-19 12:10:53 +02:00
parent 0e98ddeef4
commit f3a83256a8

View File

@@ -135,17 +135,22 @@ class ReadingProgressController {
authors: [pubkey]
})
// Subscribe to get initial events synchronously
const subscription = timeline.subscribe((localEvents) => {
console.log('📊 [ReadingProgress] Found', localEvents.length, 'events in local store')
if (localEvents.length > 0) {
this.processEvents(localEvents)
}
// 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 immediately after getting initial value
// Unsubscribe after getting value
subscription.unsubscribe()
console.log('📊 [ReadingProgress] Processing', localEvents.length, 'events from local store')
if (localEvents.length > 0) {
this.processEvents(localEvents)
}
// 2. Then fetch from relays (incremental or full) to augment local data
const lastSynced = force ? null : this.getLastSyncedAt(pubkey)
const filter: any = {