Skip to content

feat(web): paginate the audio transactions page#14381

Merged
rickyrombo merged 2 commits into
mainfrom
mp/audio-transactions-pagesize-cap
May 21, 2026
Merged

feat(web): paginate the audio transactions page#14381
rickyrombo merged 2 commits into
mainfrom
mp/audio-transactions-pagesize-cap

Conversation

@rickyrombo
Copy link
Copy Markdown
Contributor

@rickyrombo rickyrombo commented May 21, 2026

Summary

Replaces the "fetch everything in one shot" pattern on the AUDIO transactions page with proper infinite pagination, matching what the USDC purchases / sales / withdrawals tables already do.

Background

`AudioWalletTransactions.tsx` was setting `pageSize = audioTransactionsCount` so the table could render every transaction in a single fetch (the table has no built-in pagination UI). For users with more than 100 transactions, this exceeded the server-side validator on `/v1/users/{id}/transactions/audio` (`limit` max=100), and the request failed outright — power users saw an empty page.

The first commit on this branch just clamped the requested size at 100 (stopping the bleeding). This second commit replaces the workaround with real pagination.

Changes

`useAudioTransactions` (`packages/common`)

  • Convert from `useQuery` to `useInfiniteQuery` with `getNextPageParam` keyed on accumulated page count × pageSize.
  • Expose `loadNextPage` with a stable identity (ref-based, matches the pattern in `usePurchases`).
  • Default `pageSize` stays at 50.

`AudioWalletTransactions.tsx` (`packages/web`)

  • Drop the count-based `pageSize` hack and the `Math.min(..., 100)` clamp from the previous commit.
  • Pass `fetchMore={loadNextPage}`, `totalRowCount={audioTransactionsCount}`, `fetchBatchSize={DEFAULT_AUDIO_TRANSACTIONS_BATCH_SIZE}`, `isVirtualized={true}` to `AudioTransactionsTable`. Same wiring as `PurchasesTab → PurchasesTable`.

Server-side win

This also bounds the worst-case input to the slow `ORDER BY transaction_type` plan I flagged in api#844: the server can now never be asked for more than 50 rows per request, capping the cost of the materialize-and-sort plan.

Test plan

  • As a low-activity user (< 50 audio txns): page renders identically to before.
  • As a heavy user (> 50): initial fetch returns 50, scrolling triggers `loadNextPage` which fetches the next 50, repeats until `totalRowCount` is reached.
  • Sort toggles (date / transaction_type, asc / desc) reset the infinite query correctly via queryKey change.
  • Power user with > 100 txns no longer sees an empty page (the bug this branch was opened for).

🤖 Generated with Claude Code

AudioWalletTransactions.tsx requests pageSize = audioTransactionsCount
to render every transaction in one shot (the table has no pagination
UI). For users with more than 100 transactions, this exceeds the
server-side validator on /v1/users/{id}/transactions/audio (limit: max=100)
and the request fails outright — power users see an empty page.

Cap the requested page size at 100. Users with more than 100 now see
the most recent 100; users with fewer keep current behavior.

A proper "load more" affordance is the right long-term fix; this is
just stopping the bleeding.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 8f4de71

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Replaces the "fetch everything in one shot, capped at 100" workaround
with proper infinite pagination, matching the pattern used by the USDC
purchases / sales / withdrawals tables.

- useAudioTransactions: convert from useQuery to useInfiniteQuery,
  expose loadNextPage with a stable identity (same shape as usePurchases).
  pageSize defaults to 50, requested per page.
- AudioWalletTransactions: drop the audioTransactionsCount-based
  pageSize hack and the Math.min(..., 100) clamp from the previous
  commit. Wire fetchMore + totalRowCount + isVirtualized into
  AudioTransactionsTable so it loads more rows as the user scrolls.

The previous commit's clamp is no longer needed — the new hook always
requests pageSize<=50 per page.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@pull-request-size pull-request-size Bot added size/M and removed size/S labels May 21, 2026
@rickyrombo rickyrombo changed the title fix(web): cap audio-transactions page size at server max (100) feat(web): paginate the audio transactions page May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

🌐 Web preview ready

Preview URL: https://audius-web-preview-pr-14381.audius.workers.dev

Unique preview for this PR (deployed from this branch).
Workflow run

@rickyrombo rickyrombo merged commit 32c0ca9 into main May 21, 2026
9 checks passed
@rickyrombo rickyrombo deleted the mp/audio-transactions-pagesize-cap branch May 21, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant