[Perf] Use bundled related entities in notifications, drop N+1 fetches#14287
Merged
Conversation
Instruments three key contest interactions following the existing
'Remix Contest:' event prefix and {remixContestId, trackId} property
shape used by the host/pick-winners events:
- REMIX_CONTEST_VIEW: contest page/screen first resolves trackId+eventId
- REMIX_CONTEST_ENTER: user taps Enter Contest / Upload Remix
- REMIX_CONTEST_VIEW_SUBMISSIONS: user opens the submissions tab
Mobile submissions-tab firing uses useFocusedTab from
react-native-collapsible-tab-view because the contest tabs mount
eagerly (lazy: false) — a plain mount effect would fire even for
users who only view the Details tab.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The /v1/notifications endpoint now returns a `related` block containing users, tracks, and playlists referenced by the page. Read those directly to prime the tan-query cache instead of firing separate useUsers / useTracks / useCollections fetches per page. - Regenerate NotificationsResponse model with `related?: Related` - Extend primeRelatedData to handle playlists alongside users/tracks - Rewrite useNotifications: drop collectEntityIds, drop the three prefetch hooks, drop the last-page hold-back logic, drop isAllPending and the manual getNotifications type cast - Switch callers (NotificationPanel, NotificationPage, NotificationList) from isAllPending alias to isPending - Fix rollup.config.ts to read package.json via fs.readFileSync and use a named import for @rollup/plugin-babel so the SDK builds on Node 22 (per repo .nvmrc) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
…Page Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14287.audius.workers.dev Unique preview for this PR (deployed from this branch). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/notificationsendpoint now returns arelatedblock ({ users, tracks, playlists }) hydrated server-side (api PR #799). Read those directly to prime the tan-query cache instead of firing N+1 secondary fetches per page.useUsers/useTracks/useCollectionsprefetch calls fromuseNotifications, the per-type ID-collection walker, and the last-page hold-back gating.isAllPendingfield on the hook result; callers now use the standardisPendingdirectly.Changes
NotificationsResponsemodel withrelated?: Related(paired with the swagger fix in AudiusProject/api PR forfix/swagger-notifications-related-field). One-file regen diff — no incidental churn.packages/common—useNotificationsrewritten to callprimeRelatedData({ related: response.related, queryClient })once per page. Manual SDK type cast forgetNotificationsremoved (proper type now flows through).primeRelatedDataextended to also seed playlists viaprimeCollectionData.packages/web+packages/mobile—NotificationPanel,NotificationPage,NotificationListupdated to readisPendingdirectly from the query result.packages/sdk/rollup.config.tssonpm run build:sdkworks on Node 22 (the version pinned by.nvmrc): readpackage.jsonviafs.readFileSync(instead of an ESM JSON import, which--configPlugin typescriptdownlevels to the unsupportedassert { type: 'json' }syntax) and use a named import for@rollup/plugin-babel(its CJS default-export shim doesn't survive ESM interop in modern Node).Test plan
tsc --noEmitinpackages/common— refactored code typechecks (pre-existing unrelated errors only)npm run build:sdksucceeds on Node 22.21.1 (verified locally; was failing prior to the rollup fix)/v1/notificationsrequest per page (no follow-up/users,/tracks,/playlistsround-trips)Notes
relatedlives at the response root (sibling todata), not per-notification — mirrors thedata/relatedenvelope already used by the comments endpoints. Per-page cache-seed instead of per-notification.related(already merged in api Add karma to trending #799). The swagger schema catch-up is a separate small PR in the api repo.🤖 Generated with Claude Code