fix(detail): auto-dismiss "Load remote images" snack bar #548

Merged
guettlibot merged 1 commits from refs/pull/548/head into main 2026-06-08 19:59:51 +00:00
guettlibot commented 2026-06-08 17:24:06 +00:00 (Migrated from codeberg.org)

Summary

  • The "Load remote images" snack bar in single-mail view (and the analogous thread view) never disappeared on its own — the user had to interact with it.

  • Flutter's SnackBar defaults to persist: true whenever an action is provided (see flutter/lib/src/material/snack_bar.dart: persist = persist ?? action != null), which short-circuits the duration-based dismiss timer in ScaffoldMessengerState.build:

    _snackBarTimer = Timer(snackBar.duration, () {
      if (snackBar.persist) return;          // <-- here
      hideCurrentSnackBar(reason: SnackBarClosedReason.timeout);
    });
    

    So the explicit duration: 3s was set, but the "View" action made the snack bar persistent and the timer's callback returned early.

  • Pass persist: false explicitly on both snack bars so the 3-second timer fires and the snack bar slides away on its own, while the "View" action button still works to navigate to the trusted-senders settings.

Test plan

  • Added widget regression test in test/widget/email_detail_screen_test.dart (Load remote images snack bar auto-dismisses after 3 seconds).
  • Added analogous test in test/widget/thread_detail_screen_test.dart.
  • task test-widget — all 174 widget tests pass.
  • scripts/run_unit_tests.sh — all 552 unit tests pass.
  • fvm dart analyze --fatal-infos on changed files — no issues.
  • fvm dart format — no diffs.
  • Manual: open a single mail with HTML body from an untrusted sender; tap "Load remote images"; verify the snack bar appears, images load, and the snack bar disappears after ~3 seconds while the "View" action button still navigates to /accounts/trusted-senders when tapped.

Closes #484

## Summary - The "Load remote images" snack bar in single-mail view (and the analogous thread view) never disappeared on its own — the user had to interact with it. - Flutter's `SnackBar` defaults to `persist: true` whenever an `action` is provided (see `flutter/lib/src/material/snack_bar.dart`: `persist = persist ?? action != null`), which short-circuits the duration-based dismiss timer in `ScaffoldMessengerState.build`: ```dart _snackBarTimer = Timer(snackBar.duration, () { if (snackBar.persist) return; // <-- here hideCurrentSnackBar(reason: SnackBarClosedReason.timeout); }); ``` So the explicit `duration: 3s` was set, but the "View" action made the snack bar persistent and the timer's callback returned early. - Pass `persist: false` explicitly on both snack bars so the 3-second timer fires and the snack bar slides away on its own, while the "View" action button still works to navigate to the trusted-senders settings. ## Test plan - [x] Added widget regression test in `test/widget/email_detail_screen_test.dart` (`Load remote images snack bar auto-dismisses after 3 seconds`). - [x] Added analogous test in `test/widget/thread_detail_screen_test.dart`. - [x] `task test-widget` — all 174 widget tests pass. - [x] `scripts/run_unit_tests.sh` — all 552 unit tests pass. - [x] `fvm dart analyze --fatal-infos` on changed files — no issues. - [x] `fvm dart format` — no diffs. - [ ] Manual: open a single mail with HTML body from an untrusted sender; tap "Load remote images"; verify the snack bar appears, images load, and the snack bar disappears after ~3 seconds while the "View" action button still navigates to `/accounts/trusted-senders` when tapped. Closes #484
Sign in to join this conversation.