Skip to content

fix: address feedback on large-wallet changes #1388

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

Merged
merged 12 commits into from
May 12, 2025

Conversation

HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented May 6, 2025

Issue being fixed or feature implemented

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Summary by CodeRabbit

  • Refactor
    • Improved thread safety and readability in background services.
    • Updated naming for identity checks to be more specific and consistent across the app.
    • Enhanced error handling with explicit exceptions for missing or uninitialized data.
    • Introduced debounced updates for coin amount entry to reduce unnecessary operations.
    • Improved null safety and replaced deprecated flows with modern equivalents.
    • Modified dialog interactions to delay actions until after user confirmation.
  • Bug Fixes
    • Prevented potential crashes by adding null checks and safer property access.
  • Chores
    • Cleaned up unused imports and renamed test variables for clarity.
  • New Features
    • Added confirmation callback support to the MixDashFirstDialogFragment for improved user interaction flow.

@HashEngineering HashEngineering self-assigned this May 6, 2025
Copy link
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

This update refactors thread safety and error handling in several wallet components. It marks authenticationGroupExtension as volatile, replaces forced non-null assertions with explicit exceptions and null checks, and updates identity checks from hasIdentity to hasBlockchainIdentity. Mutex usage is modernized, and debounced state flows are introduced for coin amount updates. Additionally, dialog interaction flow is enhanced with callback support.

Changes

File(s) Change Summary
wallet/src/de/schildbach/wallet/WalletApplication.java Marked authenticationGroupExtension as volatile for thread safety.
wallet/src/de/schildbach/wallet/service/CoinJoinService.kt Replaced manual mutex lock/unlock with withLock for structured concurrency.
wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt
wallet/src/de/schildbach/wallet/ui/TransactionResultViewModel.kt
wallet/src/de/schildbach/wallet/ui/dashpay/FrequentContactsLiveData.kt
Changed identity check from hasIdentity to hasBlockchainIdentity.
wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt Renamed property to hasBlockchainIdentity; improved error handling with explicit exceptions and null checks; removed unused imports.
wallet/src/de/schildbach/wallet/ui/payments/PaymentsViewModel.kt Added null safety for wallet access; replaced flowOf() with emptyFlow() for certain flows; updated imports accordingly.
wallet/src/de/schildbach/wallet/ui/send/SendCoinsFragment.kt Updated amount propagation to use setAmount() method instead of direct property assignment.
wallet/src/de/schildbach/wallet/ui/send/SendCoinsViewModel.kt Refactored currentAmount to use a debounced StateFlow and added setAmount() method; removed direct coroutine launch in setter.
wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.kt Replaced forced non-null assertion with safe call for wallet?.reset().
wallet/src/de/schildbach/wallet/ui/main/MainActivity.kt Changed dialog show call to include a callback that starts CreateUsernameActivity after dialog completion.
wallet/src/de/schildbach/wallet/ui/more/MixDashFirstDialogFragment.kt Added nullable onConfirm lambda property and overloaded show method to accept a callback.
wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt Modified dialog show call to include a callback that starts CreateUsernameActivity after dialog display.
wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt Renamed mocked dependency to deviceInfoProvider and cleaned up unused imports.

Sequence Diagram(s)

sequenceDiagram
    participant UI as SendCoinsFragment
    participant VM as SendCoinsViewModel

    UI->>VM: setAmount(amount)
    VM->>VM: Update _currentAmount StateFlow
    Note over VM: Debounce 150ms
    VM->>VM: Execute dry run (after debounce)
Loading
sequenceDiagram
    participant Activity as MainActivity
    participant Dialog as MixDashFirstDialogFragment
    participant CreateUsername as CreateUsernameActivity

    Activity->>Dialog: show(activity, onConfirm)
    Dialog-->>Activity: onConfirm callback invoked
    Activity->>CreateUsername: startActivity()
Loading

Possibly related PRs

Suggested reviewers

  • Syn-McJ

Poem

In the warren of code, threads hop and race,
Volatile fields keep them in place.
Identity checks, now blockchain-bound,
Safer mutexes quietly surround.
With debounced flows and nulls in check,
This code hops forward—oh, what the heck!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 b943642 and 0f7b2b7.

📒 Files selected for processing (3)
  • wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.kt (2 hunks)
  • wallet/src/de/schildbach/wallet/ui/more/MixDashFirstDialogFragment.kt (3 hunks)
  • wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • wallet/src/de/schildbach/wallet/ui/more/MixDashFirstDialogFragment.kt
  • wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.kt
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt (1)

177-179: Improved dialog callback implementation.

The code now uses a lambda callback when showing MixDashFirstDialogFragment instead of relying on the dialog to directly handle navigation. This centralizes navigation logic in the parent fragment and improves maintainability by making the flow more explicit.

✨ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

Copy link
Contributor

@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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 881b726 and b943642.

📒 Files selected for processing (3)
  • wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.kt (1 hunks)
  • wallet/src/de/schildbach/wallet/ui/main/MainActivity.kt (1 hunks)
  • wallet/src/de/schildbach/wallet/ui/more/MixDashFirstDialogFragment.kt (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (2)
wallet/src/de/schildbach/wallet/service/BlockchainServiceImpl.kt (1)

1053-1053: Improved null safety handling.

The change from wallet!!.reset() to wallet?.reset() prevents potential null pointer exceptions by only calling the reset method if the wallet instance is not null. This is aligned with Kotlin best practices and makes the code more robust.

wallet/src/de/schildbach/wallet/ui/main/MainActivity.kt (1)

260-262: Flow improvement with callback-based dialog interaction

The code now correctly uses a callback approach for dialog interaction, deferring the CreateUsernameActivity start until after dialog confirmation. This is a good improvement in control flow.

@HashEngineering HashEngineering merged commit 6e22af3 into master May 12, 2025
3 checks passed
@Syn-McJ Syn-McJ deleted the fix/large-wallet-fixes branch May 13, 2025 07:03
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