Skip to content

feat: migrate GitHub stars fetch to TanStack Query#1215

Merged
MODSetter merged 1 commit intoMODSetter:devfrom
mvanhorn:feat/1198-tanstack-query-github-stars
Apr 11, 2026
Merged

feat: migrate GitHub stars fetch to TanStack Query#1215
MODSetter merged 1 commit intoMODSetter:devfrom
mvanhorn:feat/1198-tanstack-query-github-stars

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 11, 2026

Replaces the manual useEffect + fetch pattern in NavbarGitHubStars with useQuery from @tanstack/react-query, matching how the rest of the codebase handles data fetching.

What changed:

  • github-stars-badge.tsx: Replaced useState + useEffect + manual AbortController with a single useQuery call. The abort signal is provided by TanStack Query automatically. Added a 5-minute staleTime so the star count isn't re-fetched on every navigation.
  • cache-keys.ts: Added github.repoStars cache key for the query.

Note: The useLatestRelease hook in hero-section.tsx mentioned in #1198 has already been removed from the codebase, so only the stars badge needed migration.

Re-submitting against dev per maintainer request (previously #1213 which targeted main).

Closes #1198

High-level PR Summary

This PR migrates the GitHub stars fetching logic from a manual useEffect and fetch pattern to TanStack Query's useQuery hook, aligning with the existing data fetching conventions in the codebase. The changes replace manual state management and abort controller handling with TanStack Query's built-in capabilities, and add a 5-minute stale time to prevent unnecessary refetches during navigation.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/lib/query-client/cache-keys.ts
2 surfsense_web/components/homepage/github-stars-badge.tsx

Need help? Join our Discord

Analyze latest changes

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
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

@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.

Copy link
Copy Markdown

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 7ec2973..b655023

✨ 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

@MODSetter MODSetter merged commit 43c8590 into MODSetter:dev Apr 11, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants