Skip to content

Updates and improvements on hifi-endpoint#288

Merged
RanaBug merged 1 commit intostagingfrom
fix/PRO-3190/hifi-endpoint-replacement
Apr 16, 2025
Merged

Updates and improvements on hifi-endpoint#288
RanaBug merged 1 commit intostagingfrom
fix/PRO-3190/hifi-endpoint-replacement

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Apr 15, 2025

Description

  • Latest price from market history endpoint day - Latest price per minute available
  • Native token appearing on top when searching for token
  • Token not found when clicking on token without enough data on popular/trending token and improved messaging for the user

How Has This Been Tested?

  • Unit tests and manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Added support for a customizable top margin in the Skeleton Loader component.
  • Bug Fixes

    • Improved error messages for graph and token data, providing clearer guidance when data is unavailable or an invalid asset is selected.
    • Enhanced token price display to show a loading indicator when appropriate and prioritize the latest available price.
  • Improvements

    • Increased graph data resolution for daily period to provide more granular updates.
    • Updated token search results to prioritize relevant matches at the top of the list.
  • Tests

    • Updated tests to reflect changes in price display logic and loading states.

…oken price and native token search on top of the search list
@RanaBug RanaBug requested a review from IAmKio April 15, 2025 16:45
@RanaBug RanaBug self-assigned this Apr 15, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 15, 2025

Walkthrough

This set of changes updates error messages and UI behaviors in the TokenAtlas application's graph and token information components. It introduces clearer error messaging for unavailable graph data, adds new logic for displaying the latest token price based on graph data, and incorporates a loading state for the graph. The Redux selector and local state management are enhanced, and tests are updated to reflect these changes. Additionally, the graph data resolution for the "DAY" period is changed to 1 minute, the skeleton loader component now supports a margin-top prop, and the order of token search results is adjusted to prioritize Fuse.js matches.

Changes

Files / Groups Change Summary
src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx Updated the error message for empty graph data to clarify that data may not be available for the selected timeframe.
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx Added Redux selector for graph loading state, local state for latest price, and new useEffect hooks for default period selection and price updates. Enhanced error messages and token price display logic to show skeleton loader or latest price as appropriate.
src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx Updated tests to include setIsGraphLoading dispatch, mocked the chart component, and changed assertions to reflect new latest price logic. Added ESLint disable comment for accessibility.
src/apps/token-atlas/index.tsx Modified useEffect hooks to check for the string 'undefined' in the asset query parameter, clearing token data and setting error flags if matched.
src/apps/token-atlas/utils/converters.ts Changed graph resolution for the "DAY" period from '15min' to '1min'.
src/components/SkeletonLoader.tsx Extended the SkeletonLoader component to accept an optional $marginTop prop for custom top margin styling.
src/services/tokensData.ts Changed the order of token search results to place Fuse.js matches before the original token data in the returned array.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TokenGraphColumn
    participant ReduxStore
    participant TokenGraph

    User->>TokenGraphColumn: Selects token or changes period
    TokenGraphColumn->>ReduxStore: Dispatches actions (e.g., setIsGraphLoading)
    ReduxStore-->>TokenGraphColumn: Updates graph loading state and token data
    TokenGraphColumn->>TokenGraph: Passes props (data, loading, error)
    TokenGraph-->>TokenGraphColumn: Renders graph or error message
    TokenGraphColumn-->>User: Displays latest price, skeleton loader, or error
Loading

Possibly related PRs

  • pillarwallet/x#277: Modifies fuzziness rules and search query logic in searchTokens, related to changes in src/services/tokensData.ts.
  • pillarwallet/x#284: Adds navigation and buy button to TokenGraphColumn, related to UI and state management changes in the same component.

Suggested reviewers

  • IAmKio

Poem

In the garden of tokens, the graphs now gleam,
With fresher messages and prices supreme.
Skeletons shimmer while loading anew,
One-minute data—crisp as the dew!
Search results leap to the front of the line,
Rabbits rejoice: the code’s looking fine.
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3a485e and 6c72619.

⛔ Files ignored due to path filters (5)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PortfolioOverview/test/__snapshots__/PortfolioOverview.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokensSlider/test/__snapshots__/TokenSlider.test.tsx.snap is excluded by !**/*.snap
  • src/components/Form/Select/__snapshots__/Select.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (4 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx (4 hunks)
  • src/apps/token-atlas/index.tsx (2 hunks)
  • src/apps/token-atlas/utils/converters.ts (1 hunks)
  • src/components/SkeletonLoader.tsx (1 hunks)
  • src/services/tokensData.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/components/SkeletonLoader.tsx (1)
src/theme/index.ts (1)
  • animation (220-226)
src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx (1)
src/apps/token-atlas/reducer/tokenAtlasSlice.ts (2)
  • setPeriodFilter (101-103)
  • setIsGraphLoading (104-106)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (17)
src/components/SkeletonLoader.tsx (1)

11-11: LGTM! Good enhancement to the SkeletonLoader component.

Adding the $marginTop prop follows the existing pattern for other margin controls and increases the component's flexibility for positioning in different UI contexts.

Also applies to: 18-18

src/apps/token-atlas/utils/converters.ts (1)

34-35: Improved graph granularity for day period.

Changing the resolution from 15min to 1min will provide more detailed and precise graph data for the day period, which aligns with the PR objective of providing latest price data per minute.

src/services/tokensData.ts (1)

385-385: Improved search results prioritization.

Changing the order of concatenation prioritizes the Fuse.js search results, which aligns perfectly with the PR objective of prioritizing native tokens in search results. Users will now see the most relevant matches at the top of the search results.

src/apps/token-atlas/index.tsx (2)

236-239: Better handling of invalid asset parameter.

Adding a check for asset === 'undefined' provides a guard against showing incorrect data when the asset parameter is invalid, improving the error state handling.


252-255: Consistent error handling for graph data.

This change mirrors the error handling improvement applied to token data, ensuring consistent behavior when an invalid asset parameter is detected. This supports the PR objective of improving messaging in "token not found" scenarios.

src/apps/token-atlas/components/TokenGraph/TokenGraph.tsx (1)

145-147: Improved error message for better user guidance

The updated error message now clearly explains that the issue might be due to unavailable data for the specific timeframe, providing users with more actionable guidance.

src/apps/token-atlas/components/TokenGraphColumn/test/TokenGraphColumn.test.tsx (5)

1-1: Added ESLint suppression for accessibility warning

This suppression is necessary due to the canvas mock implementation using a non-interactive role.


18-18: Added import for new Redux action

Correctly imports the new setIsGraphLoading action to support testing the loading state functionality.


89-94: Added mock for Line component

The mock implementation appropriately simplifies the chart rendering for test purposes, using a basic canvas element with the correct test ID.


101-101: Added initialization of graph loading state

Properly sets up the test environment by initializing the loading state to false, ensuring consistent test behavior.


133-133: Updated price assertion to match component changes

The test now correctly verifies the latest closing price from the graph data (46050.5) instead of the original token info price (105), reflecting the component's updated logic for displaying prices.

src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (6)

69-71: Added Redux selector for graph loading state

Correctly implements a selector to track the loading state of the graph, enabling proper UI feedback during data fetching.


75-75: Added state for latest price tracking

Good addition of local state to store and manage the most recent closing price from graph data.


144-147: Added effect to set default period filter

This effect ensures consistent initial view by setting the period filter to "DAY" whenever token data changes.

Note that this will reset the user's timeframe selection whenever token data changes. Verify this is the intended behavior, as it might disrupt user experience if they had selected a different timeframe.


149-161: Added effect to update latest price from graph data

Well-implemented effect that updates the latest price from graph data when conditions are met. The implementation includes proper checks for data availability and loading state.


225-227: Improved error message for better user guidance

The updated error message provides clearer information about potential causes of the error and suggests appropriate actions, enhancing the user experience.


238-255: Enhanced price display logic with loading state

Good implementation of conditional rendering that shows:

  1. A skeleton loader during loading (for DAY period)
  2. Latest price from graph data when available
  3. Falls back to token info price when needed

This provides better user feedback and ensures the most recent price information is displayed.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c72619
Status: ✅  Deploy successful!
Preview URL: https://4f00990b.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3190-hifi-endpoint-r.x-e62.pages.dev

View logs

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@RanaBug RanaBug merged commit debacac into staging Apr 16, 2025
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 23, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants