perf(market): paginate Nostr offer discovery, infinite scroll, memory cap
Bound market memory and let large areas page instead of loading everything: - DiscoveryQuery gains an until cursor; OfferTransport gains discoverPage() (one-shot, EOSE-bounded, newest-first) alongside the existing live discover() stream, which now accepts since so it only carries NEW offers going forward. - NostrOfferTransport.discoverPage sorts by created_at desc and derives the next cursor from the oldest event seen (not the oldest type-matched one, so filtering never skips a page). - OffersCubit: discover() fetches the first page + opens a since=now live sub; loadNextPage() pages further back; the in-memory list is capped at 400 offers (each can carry a ~40KB inline photo thumbnail, so unbounded growth in a busy area was a real OOM risk). - market_screen: infinite scroll via a scroll-position trigger + footer spinner, instead of a single unbounded ListView. - Added discoverPage unit tests (commons_core) and cubit pagination tests (first page/cursor, accumulation, cap, cross-page dedup).
This commit is contained in:
parent
3de01bd948
commit
f17ae7751c
9 changed files with 513 additions and 43 deletions
|
|
@ -156,7 +156,11 @@ class _SeededOffersCubit extends OffersCubit {
|
|||
/// A transport that is present (so the market reads as online) but never used.
|
||||
class _NoopOfferTransport implements OfferTransport {
|
||||
@override
|
||||
Stream<Offer> discover(DiscoveryQuery query) => const Stream.empty();
|
||||
Stream<Offer> discover(DiscoveryQuery query, {int? since}) =>
|
||||
const Stream.empty();
|
||||
@override
|
||||
Future<OfferPage> discoverPage(DiscoveryQuery query) async =>
|
||||
const OfferPage(offers: []);
|
||||
@override
|
||||
Future<PublishResult> publish(Offer offer) => throw UnimplementedError();
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue