From 4fac5f42c9951ad17f3f3aa5aab4b8afc52ba569 Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 19 Oct 2025 12:17:38 +0200 Subject: [PATCH] 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.) --- src/services/readingProgressController.ts | 27 ++--------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/services/readingProgressController.ts b/src/services/readingProgressController.ts index 9ac1002e..d0234e42 100644 --- a/src/services/readingProgressController.ts +++ b/src/services/readingProgressController.ts @@ -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],