feat: migrate GitHub stars fetch to TanStack Query#1213
Closed
mvanhorn wants to merge 1 commit intoMODSetter:mainfrom
Closed
feat: migrate GitHub stars fetch to TanStack Query#1213mvanhorn wants to merge 1 commit intoMODSetter:mainfrom
mvanhorn wants to merge 1 commit intoMODSetter:mainfrom
Conversation
Replace the manual useEffect + fetch in NavbarGitHubStars with useQuery from @tanstack/react-query. This gives the component caching, request deduplication, automatic retries, and devtools visibility for free. The useLatestRelease hook referenced in the issue has already been removed from hero-section.tsx, so only the stars badge needed migration. Closes MODSetter#1198
|
@mvanhorn is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on 7c61668..9cfaa72
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (2)
• surfsense_web/components/homepage/github-stars-badge.tsx
• surfsense_web/lib/query-client/cache-keys.ts
Owner
|
@mvanhorn Please raise PR's on |
Contributor
Author
|
Apologies for the wrong branch, re-submitted against |
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.
Replaces the manual
useEffect+fetchpattern inNavbarGitHubStarswithuseQueryfrom@tanstack/react-query, matching how the rest of the codebase handles data fetching.What changed:
github-stars-badge.tsx: ReplaceduseState+useEffect+ manualAbortControllerwith a singleuseQuerycall. The abort signal is provided by TanStack Query automatically. Added a 5-minutestaleTimeso the star count isn't re-fetched on every navigation.cache-keys.ts: Addedgithub.repoStarscache key for the query.Note: The
useLatestReleasehook inhero-section.tsxmentioned in #1198 has already been removed from the codebase, so only the stars badge needed migration.Closes #1198
High-level PR Summary
This PR migrates the GitHub stars fetching logic from a manual
useEffectandfetchpattern to TanStack Query'suseQueryhook, aligning with the codebase's standard data fetching approach. The change introduces a cache key for the GitHub stars query and adds a 5-minutestaleTimeto reduce unnecessary API calls during navigation. The migration simplifies the component by removing manual state management andAbortControllerhandling, which TanStack Query provides automatically.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_web/lib/query-client/cache-keys.tssurfsense_web/components/homepage/github-stars-badge.tsx