Fix private leagues not populating in Trade for Items league selection - #10211
Draft
everix1992 wants to merge 5 commits into
Draft
Fix private leagues not populating in Trade for Items league selection#10211everix1992 wants to merge 5 commits into
everix1992 wants to merge 5 commits into
Conversation
The trade site league endpoint only recognizes cookie sessions and silently ignores the OAuth bearer token, so private leagues never appeared after the OAuth port. Fetch them from the account API (which honors the token) and refresh the league list after login or a background token refresh. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- Build the account API auth header at send time instead of reusing one captured before the trade request, so a token refreshed mid-flight no longer 401s silently - Fetch /account/leagues once per refresh (memoized per token, in-flight requests shared) instead of once per realm - Guard both league-fetch callback paths against stale or duplicate writes when a login/refresh refetch supersedes an in-flight fetch - Record the fetch token only on a clean fetch so failures retry, and surface private-league fetch failures as a notice - Refetch league lists on logout so private leagues leave the dropdown - Only run the auth-probe search when authenticated - Don't send the bearer token to the trade-site league endpoint (it ignores it), and tolerate a missing realm field on account leagues Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- Extract TradeQuery:FetchLeaguesForRealm so the supersede guard, base-league sorting, notices, and retry bookkeeping exist in one place instead of two diverged copies; failed fetches now leave the realm unset so they retry, and the fetch token is only recorded once every realm has a clean list - Restore the league dropdown selection by name, since a refetch can change the list order - Route the account leagues request through PoEAPI:DownloadWithRateLimit, gaining token refresh, 401 retry, and rate limiting - Refetch leagues from a single choke point via a new onAuthReset hook fired by PoEAPI:ResetDetails, covering logout, failed refreshes, and outdated scopes; the logout button now just calls ResetDetails - Coalesce concurrent token refreshes in ValidateAuth: the refresh token is single-use, so two in-flight refreshes could invalidate the session Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
- InsertRequest crashed on any policy missing from the pendingRequests init table, which broke the first authenticated account-leagues fetch; initialize the policy entry on demand and cover it with a spec - Discard an in-flight token refresh whose refresh token no longer matches current state, so a logout or new login during the refresh is not overwritten by the stale result - Track the token a league-fetch pass started with, closing the gap where a logout during an in-flight authenticated pass compared nil == nil and skipped the refetch, leaving private leagues visible - Discard private-league results that complete after logout, and re-key the cache after a transparent token rotation so it still hits Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Me8GVT6W3FLuZ8ugfYGwVv
everix1992
marked this pull request as draft
August 12, 2026 20:39
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.
The trade site league endpoint only recognizes cookie sessions and silently ignores the OAuth bearer token, so private leagues never appeared after the OAuth port. Fetch them from the account API (which honors the token) and refresh the league list after login or a background token refresh.
Note: I'm not incredibly familiar with the codebase itself here and had claude assist me in finding and fixing the issue. Feel free to change as much of the code as is needed if what's changed here is inappropriate - I just wanted to be able to search for jewels in our private league
Fixes
Description of the problem being solved:
When logged in via OAuth, private leagues are not pulled into the list of available leagues to select/search when trading for items.
Steps taken to verify a working solution:
Link to a build that showcases this PR:
No specific (or any) build is required. This applies to any account that is in a private league.
Before screenshot:
After screenshot: