Paginate the live payment proof feed (Show more / Show fewer)

The feed showed only the latest 12 of 136 recorded payouts. Now:
- chain.getPayoutsPublic(offset,limit) returns a page of the full
  reversed history plus total/offset/limit/hasMore (limit capped 100).
- /api/public/payouts accepts ?offset & ?limit (defaults 0/40, so the
  live poll + toast detection are unchanged).
- payouts.js keeps a deduped store keyed by payout key; the live poll
  refreshes the recent page while "Show more" pulls older pages 12 at a
  time (with slight overlap so a newly-arrived payout can't open a gap),
  and "Show fewer" collapses back. Verified in-browser: 12 → 48 → 136
  rows, button flips to "Show fewer", collapses to 12, 0 console errors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-15 11:16:12 -05:00
parent 95bc5bc90f
commit d36a405581
4 changed files with 88 additions and 22 deletions
+10 -3
View File
@@ -329,14 +329,21 @@ function isInTeam(id, rootId) {
return false;
}
function getPayoutsPublic() {
const recent = state ? state.payouts.slice(-40).reverse() : [];
function getPayoutsPublic(offset = 0, limit = 40) {
const off = Math.max(0, Number.isFinite(offset) ? Math.floor(offset) : 0);
const lim = Math.min(100, Math.max(1, Number.isFinite(limit) ? Math.floor(limit) : 40));
const reversed = state ? state.payouts.slice().reverse() : []; // most recent first
const page = reversed.slice(off, off + lim);
return {
updatedAt: state && state.updatedAt,
ready: !!(state && state.snapshotAt),
totals: state ? { payouts: state.totals.count, pol: +state.totals.pol.toFixed(2), members: Object.keys(state.members).length } : null,
contract: CONTRACT,
payouts: recent.map(p => ({
total: reversed.length,
offset: off,
limit: lim,
hasMore: off + lim < reversed.length,
payouts: page.map(p => ({
key: p.key, kind: p.kind, toId: p.toId, fromId: p.fromId,
level: p.level, levelName: levelName(p.level), pol: p.pol, tx: p.tx, ts: p.ts, desc: p.desc,
toAccount: state.members[p.toId] ? state.members[p.toId].account : undefined,