Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): reward pill update #1531

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

shanimal08
Copy link
Collaborator

@shanimal08 shanimal08 commented Feb 17, 2025

Description

  • added separate rewardCount counter for all wins (incl. missed)

Motivation and Context

How Has This Been Tested?

  • locally:
Screen.Recording.2025-02-17.mov

What process can a PR reviewer use to test or verify this change?

  • start mining
  • ensure counter show for all wins while in focus
  • minimize
  • ensure counter includes missed wins too
  • open rewards
  • counter should reset

Summary by CodeRabbit

  • New Features
    • Updated the wallet interface to reflect rewards more clearly during win events.
    • Enhanced reward tracking to ensure win outcomes are accurately counted and displayed.
    • Introduced a new method for managing reward counts in the state.

@shanimal08 shanimal08 marked this pull request as ready for review February 17, 2025 09:28
@shanimal08 shanimal08 requested review from brianp, PanchoBubble, peps, stringhandler, MCozhusheck, Misieq01 and mmrrnn and removed request for brianp February 17, 2025 09:29
Copy link

coderabbitai bot commented Feb 17, 2025

📝 Walkthrough

Walkthrough

The changes update the management of blockchain visualization state and its presentation in the wallet component. A variable tracking the count has been renamed from "recapCount" to "rewardCount," along with its setter function. Simultaneously, the state store is updated to include an optional "rewardCount" property and a corresponding "setRewardCount" method. The win handling logic now increments the reward count instead of the recap count, while the overall control flow and functionality remain consistent.

Changes

File(s) Change Description
src/containers/main/SideBar/components/Wallet/Wallet.tsx Renamed state variable recapCount to rewardCount and its setter from setRecapCount to setRewardCount, with all associated references and conditional checks updated accordingly.
src/store/useBlockchainVisualisationStore.ts Added an optional rewardCount property to the state interface and a new method setRewardCount to the actions interface; updated the handleWin function to increment rewardCount on win events.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant W as Wallet Component
    participant S as Blockchain Store

    U->>W: Trigger win event
    W->>S: Execute handleWin()
    S->>S: Increment rewardCount
    S-->>W: Return updated state
    W-->>U: Render updated reward count
Loading

Possibly related PRs

  • fix: missed wins counter #1498: The changes in the main PR are related to the modifications of the recapCount and setRecapCount variables in the Wallet.tsx file, which are directly connected to the handling of the wallet's state, while the retrieved PR also modifies the same file but focuses on the removal of a line that sets recapCount to undefined, indicating a direct relationship in the management of wallet state variables.

Suggested reviewers

  • brianp
  • MCozhusheck
  • Misieq01
  • mmrrnn

Poem

Oh, I’m a rabbit with a happy hop,
Changing names with a joyful bop.
"Reward" now leaps in line, so neat,
Incrementing counts with every beat.
In code’s garden, I sniff and cheer,
For fresh updates now appear!
🐰✨


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afb65ae and 34a28e5.

📒 Files selected for processing (1)
  • src/containers/main/SideBar/components/Wallet/Wallet.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/containers/main/SideBar/components/Wallet/Wallet.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: tauri-build

🪧 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. (Beta)
  • @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.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/store/useBlockchainVisualisationStore.ts (1)

64-64: Consider using nullish coalescing for better readability.

The increment logic is correct and properly placed before the animation check, ensuring all wins are counted. However, the fallback logic could be more readable.

-    useBlockchainVisualisationStore.setState((curr) => ({ rewardCount: (curr.rewardCount || 0) + 1 }));
+    useBlockchainVisualisationStore.setState((curr) => ({ rewardCount: (curr.rewardCount ?? 0) + 1 }));
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cfb5cb and afb65ae.

📒 Files selected for processing (2)
  • src/containers/main/SideBar/components/Wallet/Wallet.tsx (3 hunks)
  • src/store/useBlockchainVisualisationStore.ts (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: tauri-build
🔇 Additional comments (6)
src/store/useBlockchainVisualisationStore.ts (2)

23-23: LGTM!

The rewardCount property is correctly typed as an optional number, aligning with the PR objective to track all wins, including missed ones.


33-33: LGTM!

The setRewardCount method signature is consistent with the state property type and follows the existing pattern.

src/containers/main/SideBar/components/Wallet/Wallet.tsx (4)

32-33: LGTM!

The hooks correctly access the store's state and actions for reward count management.


43-43: LGTM!

The reward count is correctly reset when showing history, and the useCallback dependencies are properly updated.

Also applies to: 47-47


53-53: LGTM!

The condition for showing the count is comprehensive and correctly handles all edge cases.


72-72: LGTM!

The reward count is correctly displayed in the badge when conditions are met.

@@ -40,17 +40,17 @@ export default function Wallet() {
}
if (transactions.length || is_reward_history_loading) {
// Question(A): Not sure what this was for
setRecapCount(undefined);
setRewardCount(undefined);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could clear the reward count after opening the history. It looks like it's cleared too early

Copy link
Collaborator

@mmrrnn mmrrnn left a comment

Choose a reason for hiding this comment

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

Tested successfully on linux

image

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