fix: remove delete confirmation dialog from thread view (#402)
## Summary - Removes the `AlertDialog` popup that appeared when tapping delete in thread view - Deletion now happens immediately, matching the behaviour of the single mail view - The existing `UndoShell` widget already listens for new `UndoAction` pushes and shows a snack bar with an **Undo** button — no extra UI code needed Closes #398 Co-authored-by: Thomas SharedInbox <sharedinbox@thomas-guettler.de> Reviewed-on: https://codeberg.org/guettli/sharedinbox/pulls/402
This commit was merged in pull request #402.
This commit is contained in:
committed by
guettli
co-authored by
guettli
Thomas SharedInbox
parent
582f6764eb
commit
b0354c7423
@@ -297,47 +297,27 @@ class _EmailMessageCardState extends ConsumerState<_EmailMessageCard> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _delete() async {
|
Future<void> _delete() async {
|
||||||
final confirmed = await showDialog<bool>(
|
final repo = ref.read(emailRepositoryProvider);
|
||||||
context: context,
|
// Fetch data first for IMAP undo support
|
||||||
builder: (ctx) => AlertDialog(
|
final original = await repo.getEmail(widget.email.id);
|
||||||
title: const Text('Delete email'),
|
|
||||||
content: const Text('Move this email to Trash?'),
|
final destPath = await repo.deleteEmail(widget.email.id);
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(ctx, false),
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(ctx, true),
|
|
||||||
child: const Text('Delete'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (confirmed == true) {
|
if (original != null) {
|
||||||
final repo = ref.read(emailRepositoryProvider);
|
unawaited(
|
||||||
// Fetch data first for IMAP undo support
|
ref.read(undoServiceProvider.notifier).pushAction(
|
||||||
final original = await repo.getEmail(widget.email.id);
|
UndoAction(
|
||||||
|
id: DateTime.now().toIso8601String(),
|
||||||
final destPath = await repo.deleteEmail(widget.email.id);
|
accountId: widget.email.accountId,
|
||||||
|
type: UndoType.delete,
|
||||||
if (!mounted) return;
|
emailIds: [widget.email.id],
|
||||||
if (original != null) {
|
sourceMailboxPath: widget.email.mailboxPath,
|
||||||
unawaited(
|
destinationMailboxPath: destPath,
|
||||||
ref.read(undoServiceProvider.notifier).pushAction(
|
originalEmails: [original],
|
||||||
UndoAction(
|
|
||||||
id: DateTime.now().toIso8601String(),
|
|
||||||
accountId: widget.email.accountId,
|
|
||||||
type: UndoType.delete,
|
|
||||||
emailIds: [widget.email.id],
|
|
||||||
sourceMailboxPath: widget.email.mailboxPath,
|
|
||||||
destinationMailboxPath: destPath,
|
|
||||||
originalEmails: [original],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user