Skip to content

Conversation

@josefinalliende
Copy link
Contributor

@josefinalliende josefinalliende commented Aug 31, 2025

Description

#559 fixes an issue where metadata wasn’t updating after edits, but it added logic to the metadata cache provider, which we actually want to remove.

This PR removes that provider from the General Settings screen and (hopefully) fixes the same issue as #559, unless I’m missing something.

It still relies on ContactModel, which we also want to remove. But I think it’s easier to first remove the metadata cache provider and then rename that model to something like UserData (or another better name you might suggest). The idea is to have a model that represents metadata + pubkey in a way that’s easier for widgets to handle.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore
  • 🧪 Tests

Checklist

  • Run just precommit to ensure that formatting and linting are correct
  • Run just check-flutter-coverage to ensure that flutter coverage rules are passing
  • Updated the CHANGELOG.md file with your changes (if they affect the user experience)

Summary by CodeRabbit

  • Bug Fixes

    • More reliable contact details loading, reducing stale or missing info and eliminating occasional “Unknown User” entries.
    • Improved active account detection for greater stability during app launch and account switching.
    • Smoother, more consistent loading on the General Settings screen.
  • Refactor

    • Streamlined how account metadata and the active account are obtained to improve robustness and consistency without changing user workflows.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Refactors GeneralSettingsScreen to fetch per-account metadata directly via accountMetadata and to resolve the active account through activeAccountProvider.future. Removes metadata cache usage and fallback logic. Updates ContactModel construction to fromMetadata. Narrows accounts.dart imports to Account, getAccounts, and accountMetadata.

Changes

Cohort / File(s) Summary
General settings screen: active account & metadata retrieval
lib/ui/settings/general_settings_screen.dart
- Replace metadata cache reads with direct accountMetadata(pubkey)
- Construct contacts via ContactModel.fromMetadata(publicKey, metadata)
- Use activeAccountProvider.future to get current ActiveAccountState.account
- Remove metadata_cache_provider import and cache-miss handling
- Restrict accounts.dart import to Account, getAccounts, accountMetadata

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as GeneralSettingsScreen
  participant Prov as activeAccountProvider
  participant API as accounts.dart
  participant Meta as accountMetadata

  User->>UI: Open screen
  UI->>Prov: read .future
  Prov-->>UI: ActiveAccountState (account)
  UI->>API: getAccounts()
  API-->>UI: List<Account>
  loop For each account
    UI->>Meta: accountMetadata(pubkey)
    Meta-->>UI: Metadata
    UI->>UI: ContactModel.fromMetadata(publicKey, metadata)
  end
  UI-->>User: Render accounts with metadata

  note over UI: Cache-based retrieval removed<br/>No "Unknown User" fallbacks
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my ears at futures bright,
Hop from cacheless fields to light—
Direct metadata, crisp and clean,
Active accounts now clearly seen.
With tidy imports, I thump in cheer,
Settings bloom like springtime here.
Carrot commits! Ship it near. 🥕✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3935c42 and 302015f.

📒 Files selected for processing (1)
  • lib/ui/settings/general_settings_screen.dart (2 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/remove-metadata-cache-from-settings-screen

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@untreu2 untreu2 self-requested a review August 31, 2025 14:17
@untreu2 untreu2 marked this pull request as ready for review August 31, 2025 14:30
@josefinalliende josefinalliende merged commit 3a7f8a0 into master Aug 31, 2025
1 of 2 checks passed
@josefinalliende josefinalliende deleted the fix/remove-metadata-cache-from-settings-screen branch August 31, 2025 14:31
@coderabbitai coderabbitai bot mentioned this pull request Sep 2, 2025
11 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.

3 participants