feat(predict): Add React Query hook usePredictMarketList#30986
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| }); | ||
|
|
||
| return getVisiblePredictMarkets(deduped); | ||
| }, [queryResult.data]); |
There was a problem hiding this comment.
Disabled hook keeps cached markets
Medium Severity
When enabled is false, markets is still built from cached queryResult.data pages, so a section that was previously loaded can keep showing the old list after a feature flag or gate turns off. Sibling hooks like usePredictSearchMarketData return an empty list when disabled; legacy usePredictMarketData also clears data when enabled becomes false.
Reviewed by Cursor Bugbot for commit 0232247. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1f7d892. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |


Description
Adds a React Query (
useInfiniteQuery) market-list hook,usePredictMarketList, for the redesigned Predict homepage sections and generic feed screens (epic PRED-834 — IA & Navigation Overhaul).Reason for the change: the existing
usePredictMarketDatahook fetches with localuseState/useEffect, a hand-rolled retry loop, manual cursor tracking, and manual dedupe. The redesigned feed is built on the generic, category-freePredictController.listMarketsAPI (added previously), and needs a data hook that is declarative, cache-backed, and reusable across many sections driven only by params.Solution: a new hook built on
useInfiniteQuerythat:PredictController.listMarkets(not the category-basedgetMarkets).nextCursor(getNextPageParam).filterStandaloneMarkets, cross-page dedupe by id, andgetVisiblePredictMarkets.isLoading,isFetching,isFetchingNextPage,error,hasNextPage) plusrefetch/fetchNextPage, and anenabledoption to disable fetching.tags/series; trimmed/blanksearchandlive: falsecollapse to absent).Scope / constraints:
usePredictMarketData(category /getMarkets) is not removed and remains the old/fallback feed path.getMarkets/listMarketsserver-side code.Files:
app/components/UI/Predict/queries/marketList.ts(new) —normalizeMarketListParams,predictMarketListKeys,predictMarketListOptions.app/components/UI/Predict/queries/index.ts— registeredpredictQueries.marketList.app/components/UI/Predict/hooks/usePredictMarketList.ts(new) — the hook.app/components/UI/Predict/queries/marketList.test.tsandapp/components/UI/Predict/hooks/usePredictMarketList.test.ts(new) — tests.Changelog
CHANGELOG entry: null
Related issues
Refs: PRED-834 (IA & Navigation Overhaul)
Manual testing steps
This is a non-UI data hook; behavior is covered by unit tests with a
QueryClientwrapper (mockingPredictController.listMarkets).To run locally:
Result: 18 passed.
yarn lint:tscand ESLint on the changed files are clean.Screenshots/Recordings
N/A — no UI changes in this PR (data hook only).
Before
N/A
After
N/A
Pre-merge author checklist
team-predict+no-changelog).Performance checks (if applicable)
listMarketscontroller call is already wrapped inwithTrace(TraceName.PredictListMarkets); the hook adds error reporting viaLogger.error.Pre-merge reviewer checklist
Note
Low Risk
Additive data-layer plumbing with no production UI consumer; legacy market data path is untouched.
Overview
Adds React Query–backed infinite market listing for the redesigned Predict feed: a new
predictQueries.marketListlayer andusePredictMarketList, which callPredictController.listMarketswith param-driven filters and cursor pagination instead of the legacy category/getMarketspath.The query module normalizes list params (sorted tags/series, trimmed search,
liveonly when true, default page size) so cache keys stay stable. The hook flattens pages with per-pagefilterStandaloneMarkets+getVisiblePredictMarkets, dedupes by market id, exposes pagination/refetch/enabled, mapsisLoadingtoisInitialLoadingsoenabled: falsedoes not show a stuck skeleton, and logs fetch errors. No UI is wired yet;usePredictMarketDatais unchanged. Unit tests cover the query helpers and hook behavior.Reviewed by Cursor Bugbot for commit bc96b50. Bugbot is set up for automated code reviews on this repo. Configure here.