Repository navigation
feat(frontend): add stale price tooltip warning in FiatEquivalent when feed is older than 5 minutes - #1684
Open
aazminu wants to merge 1 commit into
Conversation
…n feed is older than 5 minutes Expose `lastUpdatedAt` from `useTokenPrice` and display an amber info indicator with an accessible tooltip (`Price estimate last updated X minutes ago`) in `FiatEquivalent` whenever `Date.now() - lastUpdatedAt > 5 * 60 * 1000`. Fixes LabsCrypt#1640
This branch has not been deployed
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.
Description
Exposes
lastUpdatedAtfromuseTokenPrice(frontend/src/hooks/useTokenPrice.ts) and renders an amber info indicator with an accessible tooltip ("Price estimate last updated X minutes ago") inFiatEquivalent(frontend/src/components/FiatEquivalent.tsx) whenever the cached token price feed is older than 5 minutes (5 * 60 * 1000ms).Type of Change
Related Issues
Closes #1640
Fixes #1640
/claim #1640
Changes Made
lastUpdatedAt(number | null) on the object returned byuseTokenPriceinfrontend/src/hooks/useTokenPrice.ts(preferringquery.data.timestampwith fallback toquery.dataUpdatedAt).getPriceStaleness(lastUpdatedAt, nowMs)andSTALE_PRICE_THRESHOLD_MS(5 * 60 * 1000) infrontend/src/components/FiatEquivalent.tsx.FiatEquivalentto render an amber info badge (data-testid="stale-price-warning",title,aria-label, androle="tooltip") reading"Price estimate last updated X minutes ago"when the price quote is older than 5 minutes.frontend/src/components/__tests__/FiatEquivalent.test.tsxcovering fresh quotes (< 5minutes), stale quotes (> 5minutes), andnull/missing price data.Testing
Test Coverage
Test Steps
npx vitest run src/components/__tests__/FiatEquivalent.test.tsx src/app/streams/[id]/__tests__/stream-details-content.test.tsx src/__tests__/a11y.test.tsxinfrontend/(29/29 tests pass).npx tsc --noEmitinfrontend/(0 errors).npx eslint src/hooks/useTokenPrice.ts src/components/FiatEquivalent.tsx src/components/__tests__/FiatEquivalent.test.tsxinfrontend/(0 errors, 0 warnings).Checklist
Additional Notes
Payout Details
0x9a51790aC01c54184bcFa067bC38f7F0E7C6F6B6