refactor: route GitHub API calls through a shared useGithubQuery hook#960
Open
cleanjunc wants to merge 4 commits intoentrius:testfrom
Open
refactor: route GitHub API calls through a shared useGithubQuery hook#960cleanjunc wants to merge 4 commits intoentrius:testfrom
cleanjunc wants to merge 4 commits intoentrius:testfrom
Conversation
Contributor
Author
|
@e35ventura @anderdc Could you please review this PR? Thanks! |
Collaborator
|
Fix conflicts. |
Contributor
Author
|
Hi @anderdc |
Contributor
|
Could you please resolve the merge conflicts so we can proceed with the review? |
Contributor
Author
|
Hi @ventura-oss |
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
Adds
useGithubQuery,githubFetch, andRateLimitErrorinsrc/api/ApiUtils.tsas the single sanctioned path for talking to GitHub from the UI. The hook wraps TanStack Query, forwards the query signal to axios for automatic cancellation, and converts a 403 withX-RateLimit-Remaining: 0into a typedRateLimitErrorcarrying the parsedX-RateLimit-Resettime. AgithubErrorMessagehelper renders the structured rate limit copy ("GitHub rate limit reached. Retries available at HH:MM.") while letting each site supply its own fallback for everything else.The seven components that previously called
axios.getagainstapi.github.comorcdn.jsdelivr.netnow route through the hook and drop their inlineuseState,useEffect, andAbortControllerglue:RepositoryCheckTab.tsx(six parallel queries: repo, community profile, tree, three search/issues counts)RepositoryCodeBrowser.tsx(repo, tree, per-path commit info with web-flow attribution preserved)PRFilesChanged.tsx(PR files plus full tree, with sparse-tree fallback when the tree fetch fails)MinerOpenDiscoveryIssuesByRepo.tsx(fetchGithubIssuesByAuthor+ per-issue timeline lookups now thread the abort signal throughgithubFetch)CodeViewer.tsx,ContributingViewer.tsx,ReadmeViewer.tsx(raw text fetches withresponseType: 'text'; the multi-branch and multi-path fallback loops re-throwRateLimitErrorso the structured message is not swallowed)The fast-click-between-PRs race on the diff viewer is gone because every site now gets cancellation for free, and rate limit failures surface with a useful message instead of a generic "Failed to load".
Related Issues
Closes #959
Type of Change
Screenshots
Not applicable. No visual changes outside the rate limit error copy, which only renders when a 403 with
X-RateLimit-Remaining: 0is observed.Checklist
npm run formatandnpm run lint:fixhave been runnpm run buildpasses