Commit 0fcafbb
chore(runway): cherry-pick feat(predict): cp-7.62.0 improve PredictGameChart with market prop and smart timeframe defaults (#24896)
- feat(predict): cp-7.62.0 improve PredictGameChart with market prop and
smart timeframe defaults (#24858)
## **Description**
This PR improves the PredictGameChart component for live NFL games by:
1. **Refactoring to accept a `market` prop** - Instead of requiring
`tokenIds` and `seriesConfig` to be passed separately, the component now
derives these internally from the market object, simplifying the API.
2. **Adding smart timeframe defaults based on game status**:
- `ongoing` games → Default to `'live'` timeframe with live price
updates
- `scheduled` games → Default to `'6h'` timeframe (no live updates)
- `ended` games → Default to `'max'` timeframe with disabled selector,
using timestamp-based queries
3. **Supporting time-range price history queries** - For ended games,
the chart now queries price history using `startTs`/`endTs` (game
start/end timestamps) instead of interval-based queries, with 2-minute
fidelity for detailed game period visualization.
4. **Showing disabled timeframe selector for ended games** - Instead of
hiding the selector entirely, it's now shown but disabled with "Max"
selected, providing better UX feedback.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: N/A (internal improvement)
## **Manual testing steps**
```gherkin
Feature: PredictGameChart smart timeframe defaults
Scenario: User views chart for ongoing game
Given user is on a game details page for an ongoing NFL game
When the page loads
Then the chart defaults to "Live" timeframe
And the timeframe selector buttons are enabled
Scenario: User views chart for scheduled game
Given user is on a game details page for a scheduled NFL game
When the page loads
Then the chart defaults to "6H" timeframe
And the timeframe selector buttons are enabled
Scenario: User views chart for ended game
Given user is on a game details page for a completed NFL game
When the page loads
Then the chart defaults to "Max" timeframe
And the timeframe selector buttons are visible but disabled
And the chart shows the full game period with detailed price history
```
## **Screenshots/Recordings**
### **Before**
N/A - Internal refactor
### **After**
N/A - Internal refactor
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes the game chart API and behavior, and wires backend support
for time-range queries.
>
> - Refactors `PredictGameChart` to accept `market` and derive
`tokenIds`/`seriesConfig`; adds `'1h'` timeframe and smart defaults:
`ongoing` → `live`, `scheduled` → `6h`, `ended` → `max`
> - Disables live updates and the timeframe selector for ended games;
passes `disabledTimeframeSelector` through `PredictGameChartContent`
> - For ended games, fetches price history via `startTs/endTs` (game
start/end) with 2-minute fidelity; otherwise uses interval-based
fetching
> - Extends `usePredictPriceHistory` and
`PolymarketProvider.getPriceHistory` to accept `startTs/endTs`; updates
logging and dependencies
> - Updates types: add `PredictMarketGame.endTime`, Polymarket API
`finishedTimestamp`; maps to `endTime` in `gameParser`
> - Simplifies `PredictGameDetailsContent` to render chart via `market`
prop
> - Comprehensive test updates and snapshot adjustments for new props,
defaults, and disabled selector
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3fb3ae2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[cb1b076](cb1b076)
Co-authored-by: Luis Taniça <matallui@gmail.com>1 parent c15e817 commit 0fcafbb
12 files changed
Lines changed: 355 additions & 285 deletions
File tree
- app/components/UI/Predict
- components
- PredictGameChart
- PredictGameDetailsContent
- __snapshots__
- hooks
- providers/polymarket
- types
- utils
Lines changed: 77 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
47 | 64 | | |
48 | | - | |
49 | | - | |
| 65 | + | |
50 | 66 | | |
51 | 67 | | |
52 | 68 | | |
53 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
54 | 91 | | |
55 | 92 | | |
56 | 93 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
60 | 115 | | |
61 | 116 | | |
62 | 117 | | |
63 | 118 | | |
64 | 119 | | |
| 120 | + | |
| 121 | + | |
65 | 122 | | |
66 | 123 | | |
67 | 124 | | |
| |||
72 | 129 | | |
73 | 130 | | |
74 | 131 | | |
75 | | - | |
| 132 | + | |
76 | 133 | | |
77 | 134 | | |
78 | 135 | | |
| |||
189 | 246 | | |
190 | 247 | | |
191 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
192 | 253 | | |
193 | 254 | | |
194 | 255 | | |
| |||
197 | 258 | | |
198 | 259 | | |
199 | 260 | | |
| 261 | + | |
200 | 262 | | |
201 | 263 | | |
202 | 264 | | |
| |||
Lines changed: 5 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
15 | 11 | | |
16 | 12 | | |
17 | 13 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 14 | + | |
22 | 15 | | |
23 | 16 | | |
24 | 17 | | |
| |||
32 | 25 | | |
33 | 26 | | |
34 | 27 | | |
| 28 | + | |
35 | 29 | | |
36 | 30 | | |
37 | 31 | | |
38 | 32 | | |
39 | | - | |
40 | | - | |
| 33 | + | |
41 | 34 | | |
42 | 35 | | |
43 | 36 | | |
| |||
0 commit comments