Client-side reducer that flattens a TanStack { pages, pageParams }
donation envelope (as returned by useInfiniteDonations) into
a single sorted TiltifyDonation[].
Two modes:
onlyReturnNew: true — stateless. On every render (when
donationsData changes), the returned array is exactly the
flatten-and-sort of the current pages.
onlyReturnNew: false (default) — sticky accumulation. The
hook keeps historic donations even after they've been dropped
from donationsData.pages (e.g. under maxPages). Donations
still in the current pages are refreshed (id-matched), and
duplicates in the accumulator are replaced with the fresh copy.
This is what an infinite-scroll column expects: rows don't
disappear when the underlying page cache trims.
flipSorting: true flips the temporal axis (oldest first). The
amount tiebreak stays descending in both modes so higher-value
donations float when timestamps match.
For a pure, stateless projection, prefer
import("@playlive/fundraiser-data").flattenDonationPages
directly — this hook only exists because the sticky-accumulation
mode needs useState.
Client-side reducer that flattens a TanStack
{ pages, pageParams }donation envelope (as returned by useInfiniteDonations) into a single sortedTiltifyDonation[].Two modes:
onlyReturnNew: true— stateless. On every render (whendonationsDatachanges), the returned array is exactly the flatten-and-sort of the current pages.onlyReturnNew: false(default) — sticky accumulation. The hook keeps historic donations even after they've been dropped fromdonationsData.pages(e.g. undermaxPages). Donations still in the current pages are refreshed (id-matched), and duplicates in the accumulator are replaced with the fresh copy. This is what an infinite-scroll column expects: rows don't disappear when the underlying page cache trims.flipSorting: trueflips the temporal axis (oldest first). The amount tiebreak stays descending in both modes so higher-value donations float when timestamps match.For a pure, stateless projection, prefer import("@playlive/fundraiser-data").flattenDonationPages directly — this hook only exists because the sticky-accumulation mode needs
useState.