Skip to content

refactor: migrate data-fetching sagas to hooks / TanStack Query#14404

Merged
dylanjeffers merged 2 commits into
mainfrom
refactor/sagas-to-tanstack-query
May 26, 2026
Merged

refactor: migrate data-fetching sagas to hooks / TanStack Query#14404
dylanjeffers merged 2 commits into
mainfrom
refactor/sagas-to-tanstack-query

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

Move pure data-fetch and localStorage-persistence side effects out of sagas and into React hooks where TanStack Query already lives. Five sagas are deleted; share-modal is trimmed to a 22-line saga that only flips modal visibility (data loading now happens in useShareContent via useTrack/useUser/useCollection).

  • cookieBanneruseEffect in WebPlayer checks shouldShowCookieBanner; CookieBanner calls the gdpr util directly on dismiss.
  • playback rate — new usePlaybackRatePersistence hook hydrates from localStorage on mount and persists on change.
  • remote-configuseEffect calls remoteConfigInstance.waitForRemoteConfig() then dispatches setDidLoad.
  • share-modal — slice now stores the request payload (type + IDs); useShareContent derives ShareContent from cached useTrack/useUser/useCollection. Modal opens immediately (vs. waiting for saga fetch); existing null guards already cover the brief loading window.
  • playback-positionusePlaybackPositionPersistence handles hydration (incl. legacy-key migration) + localStorage persistence; usePlaybackPositionPolling drives the 1s resume-position loop on web only.

userListModal was on the original audit list but turned out to be pure action routing with no data fetching — not actually a TanStack Query candidate — so it was left as-is.

Drive-by

Removed an unused isMobile prop on the named CookieBanner export in DownloadPage.tsx. The CookieBanner uses useIsMobile() internally so the prop was dead, but it was being masked by a stale @ts-ignore on the next line. Fixing the dismiss callback's return type let TypeScript catch the excess prop.

Stats

27 files changed, ~415 / -367 lines. 4 saga files deleted, 5 new hook files added.

Test plan

  • Sign in, play a long-form track, verify resume position survives reload (playback-position polling + persistence)
  • Change playback rate, reload page/app, verify rate persists (playback rate)
  • Open share modal from a track / playlist / profile, verify content populates and share/copy-link actions work (share-modal + useShareContent)
  • Cold-load on web; gated feature flags should resolve once remote config loads (remote-config didLoad)
  • EU prod: cookie banner appears and dismiss persists (cookieBanner) — hard to verify locally
  • iOS + Android: playback rate + position persistence still work
  • npm run typecheck passes for common, web, mobile (verified locally)

🤖 Generated with Claude Code

Move pure data-fetch and localStorage-persistence side effects out of
sagas into React hooks where TanStack Query already lives. Five sagas
are deleted entirely; share-modal is trimmed to a 22-line saga that
only flips the modal's visibility flag (data loading now happens in
useShareContent via useTrack/useUser/useCollection).

- cookieBanner: useEffect in WebPlayer; CookieBanner calls gdpr util
- playback rate: usePlaybackRatePersistence hydrates and persists rate
- remote-config: useEffect calls waitForRemoteConfig then setDidLoad
- share-modal: slice stores request payload; useShareContent derives
  ShareContent from cached track/user/collection queries
- playback-position: usePlaybackPositionPersistence handles localStorage
  (incl. legacy migration); usePlaybackPositionPolling drives the 1s
  resume-position loop on web

Also removes an unused isMobile prop on the named CookieBanner export
in DownloadPage (previously masked by a stale @ts-ignore).

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

changeset-bot Bot commented May 26, 2026

⚠️ No Changeset found

Latest commit: db4545c

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

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

🌐 Web preview ready

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

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

@dylanjeffers dylanjeffers merged commit fe44830 into main May 26, 2026
13 checks passed
@dylanjeffers dylanjeffers deleted the refactor/sagas-to-tanstack-query branch May 26, 2026 22:11
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