refactor: migrate data-fetching sagas to hooks / TanStack Query#14404
Merged
Conversation
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>
|
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14404.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
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
useShareContentviauseTrack/useUser/useCollection).useEffectinWebPlayerchecksshouldShowCookieBanner;CookieBannercalls the gdpr util directly on dismiss.usePlaybackRatePersistencehook hydrates from localStorage on mount and persists on change.useEffectcallsremoteConfigInstance.waitForRemoteConfig()then dispatchessetDidLoad.useShareContentderivesShareContentfrom cacheduseTrack/useUser/useCollection. Modal opens immediately (vs. waiting for saga fetch); existing null guards already cover the brief loading window.usePlaybackPositionPersistencehandles hydration (incl. legacy-key migration) + localStorage persistence;usePlaybackPositionPollingdrives the 1s resume-position loop on web only.userListModalwas 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
isMobileprop on the namedCookieBannerexport inDownloadPage.tsx. The CookieBanner usesuseIsMobile()internally so the prop was dead, but it was being masked by a stale@ts-ignoreon the next line. Fixing thedismisscallback'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
npm run typecheckpasses for common, web, mobile (verified locally)🤖 Generated with Claude Code