feat(predict): cp-7.62.0 improve chart loading state and timestamp positioning#24806
feat(predict): cp-7.62.0 improve chart loading state and timestamp positioning#24806
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsAll 7 changed files are within the
These are all self-contained changes to the Predict feature with no impact on core wallet functionality, controllers, or other features. The changes are primarily UI/UX improvements and bug fixes within the prediction market components. The SmokePredictions tag is the appropriate and only necessary tag to validate these changes. |
|
| const isLoading = | ||
| isFetching || | ||
| (isLive && !initialDataLoadedRef.current && chartData.length === 0); | ||
| isFetching || !hasChartData || (isLive && !initialDataLoadedRef.current); |
There was a problem hiding this comment.
Infinite loading spinner when no price data exists
Medium Severity
The isLoading calculation includes !hasChartData as an unconditional OR condition. When the API successfully completes (isFetching is false) but returns empty data arrays, hasChartData becomes false, making isLoading true. Since PredictGameChartContent checks isLoading before checking for empty data (!hasData), the "No price history available" message can never be displayed—instead, the loading spinner shows indefinitely.
…24806) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** - Add ActivityIndicator spinner during chart loading instead of blank background - Implement dynamic timestamp positioning to prevent text overflow at chart edges - Anchor timestamp to left when near left boundary - Anchor timestamp to right when near right boundary - Center timestamp when in the middle of the chart - Fix timestamp conversion to handle both seconds and milliseconds formats - Improve chart data loading detection to check for actual data presence - Fix TimeframeSelector padding for better spacing - Fix PredictPicks cash out button background for light mode only <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** https://www.loom.com/share/d3841593361b418e81f6034dae4a2cb2 <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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] > Improves chart usability and data handling with better loading UX, timestamp rendering, and parsing. > > - Implements edge-aware tooltip timestamp: clamps `x` to chart bounds and switches `textAnchor` between `start`/`middle`/`end` using `TIMESTAMP_TEXT_HALF_WIDTH` > - Adds `toMilliseconds` to normalize seconds vs milliseconds timestamps for history data > - Refines loading detection: require both series to have data; updates `isLoading` and initial live data logic > - Replaces blank loading state with centered `ActivityIndicator`; disables `TimeframeSelector` while loading > - UI polish: adjust `TimeframeSelector` padding; set PredictPicks cash-out button background for light mode only > - Tests: expand `ChartTooltip` tests to cover timestamp edge positioning and update SVG `Text` mock to include `textAnchor` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2cb500d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->



Description
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
https://www.loom.com/share/d3841593361b418e81f6034dae4a2cb2
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Improves chart usability and data handling with better loading UX, timestamp rendering, and parsing.
xto chart bounds and switchestextAnchorbetweenstart/middle/endusingTIMESTAMP_TEXT_HALF_WIDTHtoMillisecondsto normalize seconds vs milliseconds timestamps for history dataisLoadingand initial live data logicActivityIndicator; disablesTimeframeSelectorwhile loadingTimeframeSelectorpadding; set PredictPicks cash-out button background for light mode onlyChartTooltiptests to cover timestamp edge positioning and update SVGTextmock to includetextAnchorWritten by Cursor Bugbot for commit 2cb500d. This will update automatically on new commits. Configure here.