perf(ui): stream results to UI; show cached/local immediately (articles, highlights, explore)

This commit is contained in:
Gigi
2025-10-12 22:33:46 +02:00
parent 5513fc9850
commit ca95d6c7f4
5 changed files with 72 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
import { RelayPool, completeOnEose } from 'applesauce-relay'
import { lastValueFrom, race, takeUntil, timer, toArray } from 'rxjs'
import { RelayPool, completeOnEose, onlyEvents } from 'applesauce-relay'
import { lastValueFrom, take, takeUntil, timer, toArray } from 'rxjs'
import { nip19 } from 'nostr-tools'
import { AddressPointer } from 'nostr-tools/nip19'
import { NostrEvent } from 'nostr-tools'
@@ -119,7 +119,12 @@ export async function fetchArticleByNaddr(
events = await lastValueFrom(
relayPool
.req(localRelays, filter)
.pipe(completeOnEose(), takeUntil(timer(1200)), toArray())
.pipe(
onlyEvents(),
take(1),
takeUntil(timer(1200)),
toArray()
)
)
} catch {
events = []
@@ -131,7 +136,12 @@ export async function fetchArticleByNaddr(
events = await lastValueFrom(
relayPool
.req(orderedRelays, filter)
.pipe(completeOnEose(), takeUntil(timer(6000)), toArray())
.pipe(
onlyEvents(),
take(1),
takeUntil(timer(6000)),
toArray()
)
)
}