Skip to content

fix(mobile): in-progress feedback for the Clear local data action#2439

Merged
jjmata merged 3 commits into
we-promise:mainfrom
JSONbored:codex/mobile-clear-data-loading-state
Jun 30, 2026
Merged

fix(mobile): in-progress feedback for the Clear local data action#2439
jjmata merged 3 commits into
we-promise:mainfrom
JSONbored:codex/mobile-clear-data-loading-state

Conversation

@JSONbored

@JSONbored JSONbored commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1045 (no in-progress feedback during destructive async operations). The reset- and delete-account tiles already disable and show a spinner while their requests run — but Clear local data, which asynchronously wipes offline storage and clears the category/merchant/tag providers, had no feedback. The settings list stayed fully interactive during the wipe, inviting a second tap.

This completes the in-progress feedback across all destructive async actions in Settings.

Change

In mobile/lib/screens/settings_screen.dart, mirror the established reset/delete pattern:

  • add an _isClearingData flag, set before the work and cleared in a finally with a mounted guard;
  • give the Clear-local-data ListTile a trailing CircularProgressIndicator and enabled/onTap guards while it runs.

Screenshots

ModeBeforeAfter
Light Before – light
Before – no feedback, tile fully interactive
After – light
After – spinner + tile disabled while clearing
Dark Before – dark
Before – no feedback, tile fully interactive
After – dark
After – spinner + tile disabled while clearing

Test plan

  • flutter analyze --no-fatal-infos — no new issues
  • flutter test — green (166)

(The reset/delete loading states already in main shipped without a dedicated widget test; this mirrors that exact pattern in the same screen. SettingsScreen requires a large provider/biometric/upgrader harness to pump, so no new test is added — consistent with existing coverage.)

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced the settings screen to show a loading spinner and temporarily disable interaction while destructive operations are running (clear local data, reset account, delete account).

The reset- and delete-account tiles already disable and show a spinner
while their network calls are in flight, but "Clear local data" (an async
op that wipes offline storage and clears the category/merchant/tag
providers) had no in-progress feedback. The settings list stayed fully
interactive during the wipe, so the row could be tapped again.

Mirror the existing reset/delete pattern: add an _isClearingData flag
(set before the work, cleared in a finally with a mounted guard) and give
the tile a trailing CircularProgressIndicator plus enabled/onTap guards
while it runs. Completes the in-progress feedback across all destructive
async actions in Settings.

flutter analyze: no new issues; full suite (166) green.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

SettingsScreen consolidates per-action loading flags into a single _activeDestructiveAction state that tracks which destructive operation (clear, reset, or delete) is running. All three handlers set this state after confirmation and reset it in finally blocks. The three affected ListTiles now check this unified state to render spinners and disable interaction.

Changes

Unified Destructive Action State Management

Layer / File(s) Summary
Unified destructive action state field
mobile/lib/screens/settings_screen.dart
Adds static const action discriminators and _activeDestructiveAction as a nullable string field replacing separate boolean flags, holding 'clear', 'reset', 'delete', or null to indicate the active destructive workflow.
Destructive operation handlers
mobile/lib/screens/settings_screen.dart
_handleClearLocalData, _handleResetAccount, and _handleDeleteAccount each set _activeDestructiveAction to their action constant after confirmation and reset it to null in finally blocks to reliably manage state across success and error paths.
ListTile UI integration
mobile/lib/screens/settings_screen.dart
The "Clear local data", "Reset account", and "Delete account" ListTiles each check _activeDestructiveAction to conditionally show a spinner in trailing, disable the tile, and prevent taps when their respective action is active.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Suggested labels

mobile/Flutter

Suggested reviewers

  • jjmata

Poem

🐰 One state to rule them all, three actions in its call,
Clear, reset, delete — no more flags that sprawl.
A spinner spins, a tile goes grey, till finally clears the way,
The rabbit hops through cleaner code — hooray, hooray! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions only the 'Clear local data' action, but the actual changes implement a unified state management system (_activeDestructiveAction) for all three destructive actions (clear, reset, delete), refactoring away from scattered string literals to private constants. Update the title to reflect the broader refactoring scope, such as: 'refactor(mobile): unify destructive action state management with private constants' or similar to accurately describe the main change.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@mobile/lib/screens/settings_screen.dart`:
- Around line 760-763: The Clear local data tile and its handler
_handleClearLocalData are guarded only by the _isClearingData flag, which allows
concurrent execution with other destructive actions like reset and delete flows
that likely have their own separate flags. Create a single shared "destructive
action in progress" guard flag instead of separate flags for each destructive
action, then use this shared flag to disable all three destructive action tiles
(Clear local data, Reset, and Delete) and gate all three corresponding handlers
to prevent concurrent execution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c52d096-bf82-4066-8029-c7d5d62390fa

📥 Commits

Reviewing files that changed from the base of the PR and between fdcd0c7 and a7b26ef.

📒 Files selected for processing (1)
  • mobile/lib/screens/settings_screen.dart

Comment thread mobile/lib/screens/settings_screen.dart Outdated
Replace three independent boolean flags (_isClearingData, _isResettingAccount,
_isDeletingAccount) with a single _activeDestructiveAction string. All three
danger-zone tiles now disable together whenever any destructive operation is
running, preventing concurrent destructive actions.

@jjmata jjmata left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good fix. The consolidation into a single String? _activeDestructiveAction discriminator is cleaner than three independent booleans, and it naturally prevents two actions from running simultaneously without extra logic.

The main bug this fixes — the missing finally block on _handleClearLocalData that would have left _activeDestructiveAction stuck as 'clear' on error — is now resolved. The reset and delete paths already had finally blocks, so this brings clear into alignment.

One minor note: the three string literals 'clear', 'reset', 'delete' are scattered across the widget. If a new destructive action were added, it's easy to introduce a typo. Private constants (e.g., static const String _kClear = 'clear') would make this safer, but for three values in one widget file it's not urgent.


Generated by Claude Code

Address review feedback (jjmata): replace the scattered 'clear' / 'reset' /
'delete' string literals used for _activeDestructiveAction with private
constants (_clearAction / _resetAction / _deleteAction), defined once. The
discriminator can no longer drift via a mistyped literal across the handlers and
tiles — a typo'd constant name fails to compile. No behavior change.
@JSONbored

Copy link
Copy Markdown
Contributor Author

Thanks @jjmata — done in 7cfc725. Replaced the scattered 'clear' / 'reset' / 'delete' literals with private constants (_clearAction / _resetAction / _deleteAction) defined once, so the discriminator can't drift via a mistyped literal — a typo'd constant name now fails to compile. flutter analyze clean, full suite green (166).

@jjmata jjmata added this to the v0.7.2 milestone Jun 30, 2026
@jjmata jjmata added the mobile/Flutter Issues with the Flutter native apps label Jun 30, 2026
@jjmata jjmata merged commit bd740f1 into we-promise:main Jun 30, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mobile/Flutter Issues with the Flutter native apps

Development

Successfully merging this pull request may close these issues.

[mobile] Freeze UI until deletion is complete/add indication

2 participants