shakespeare.diy 1dfe209690 fix: move author/stats prefetch inside useFeed queryFn to eliminate race
Previously the feed had two separate systems (batch hooks in Feed.tsx +
individual hooks in NoteCard) that raced each other. The batch ran as a
useQuery at the component level, but NoteCards mounted in the same render
cycle and fired their own per-card queries before the batch resolved.
This got worse with each page as both systems scaled up.

The fix: prefetch authors and stats *inside* useFeed's queryFn, after the
feed events are fetched but before the queryFn returns. By the time React
re-renders with the new page data, the ['author', pubkey] and
['event-stats', id] caches are already populated. NoteCard's individual
useAuthor and useEventStats hooks then resolve instantly from cache
without firing any extra network requests.

New page loads only fetch authors/stats for IDs not already in cache, so
page 1's data is never re-requested when page 2 loads.

- Remove useAuthors + useBatchEventStats calls from Feed.tsx entirely
- Export computePageStats from useTrending for use in useFeed
- useBatchEventStats / useAuthors still exist for non-feed use cases

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
2026-02-18 09:58:16 -06:00
2026-02-16 16:54:01 -06:00
2026-02-16 16:54:01 -06:00
S
Description
Activist social network and fundraising platform on Nostr
AGPL-3.0 43 MiB
Languages
TypeScript 95.7%
Java 1.5%
JavaScript 0.9%
Swift 0.9%
CSS 0.5%
Other 0.4%