From d3646e350b8e6f1760490e9e7e57a238a8b45fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCttler?= Date: Sat, 25 Apr 2026 21:38:40 +0200 Subject: [PATCH] fix: surface sync errors via snackbar instead of silently swallowing them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sync button used a fire-and-forget lambda — any exception from syncEmails was discarded with no feedback. Now it awaits the call and shows a snackbar on failure, making errors visible in the UI and in tests. Co-Authored-By: Claude Sonnet 4.6 --- lib/ui/screens/email_list_screen.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ui/screens/email_list_screen.dart b/lib/ui/screens/email_list_screen.dart index 34bcbb2..289868a 100644 --- a/lib/ui/screens/email_list_screen.dart +++ b/lib/ui/screens/email_list_screen.dart @@ -133,8 +133,19 @@ class _EmailListScreenState extends ConsumerState { ), IconButton( icon: const Icon(Icons.sync), - onPressed: () => - emailRepo.syncEmails(widget.accountId, widget.mailboxPath), + onPressed: () async { + try { + await emailRepo.syncEmails( + widget.accountId, + widget.mailboxPath, + ); + } catch (e) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Sync failed: $e')), + ); + } + }, ), IconButton( icon: const Icon(Icons.edit),