fix: surface sync errors via snackbar instead of silently swallowing them

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 <noreply@anthropic.com>
This commit is contained in:
Thomas Güttler
2026-04-25 21:38:40 +02:00
co-authored by Claude Sonnet 4.6
parent 8a51496181
commit d3646e350b
+13 -2
View File
@@ -133,8 +133,19 @@ class _EmailListScreenState extends ConsumerState<EmailListScreen> {
),
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),