mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 01:07:46 +00:00
Replace the fire-once scroll detector with a viewport-fill + prefetch loop so the messages screen stays ahead of the user instead of stranding a near-empty list. One condition drives three behaviors: widen the DM time windows when the feed is empty, or when the last visible row crosses the midpoint of what's loaded. While the list is short everything is visible, so the midpoint is always crossed and it keeps widening until the list overflows the viewport with a buffer below the fold; once full it only fires again as the user scrolls past the new midpoint, so a fresh chunk lands well before the end. It stops only when the window is exhausted (reached the 10-year lookback — nothing older exists), which also gives the empty-account case a real terminating condition instead of the old runaway cascade. - TimeWindowPagination: optional geometric step growth + a hard max-lookback floor with isExhausted(), so a sparse / single-person history converges in ~10 requests. Default stays linear/unbounded; existing callers unchanged. - WindowLoadTracker: a window counts as loaded only once ALL of its relays have answered (EOSE / live event) or a timeout fires — not on the first EOSE. This stops a fast, near-empty relay from clearing the gate and letting the fill loop outrun the slow relay that holds the conversations. - Both DM loaders (NIP-17 gift wraps + NIP-04) expose loadingMore (= window still loading) and exhausted, advance in lockstep, and gate each widen on the tracker. The rooms screen shows a spinner until history is exhausted rather than flashing the empty state while older windows are still in flight.