From 22e377b5e82d972561336f7809b73115ff84f761 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 23:11:51 +0000 Subject: [PATCH 1/2] feat(notes): delete archived notes from the editor and selection menus Archived notes could only be deleted with a swipe. Add a delete option to the archived menu of the editor and of the selection app bar, which call the existing deleteNote/deleteNotes actions (the undo archives them again). Refs #595 Co-Authored-By: Claude --- lib/common/navigation/app_bars/notes/editor_app_bar.dart | 3 +++ .../app_bars/selection/notes_selection_app_bar.dart | 3 +++ .../enums/editor/editor_archived_menu_option.dart | 5 +++++ .../enums/notes/selection_archived_menu_option.dart | 7 ++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/common/navigation/app_bars/notes/editor_app_bar.dart b/lib/common/navigation/app_bars/notes/editor_app_bar.dart index bc1a7a57..3db35281 100644 --- a/lib/common/navigation/app_bars/notes/editor_app_bar.dart +++ b/lib/common/navigation/app_bars/notes/editor_app_bar.dart @@ -91,6 +91,8 @@ class _BackAppBarState extends ConsumerState { await selectLabels(context, ref, note: note); case EditorArchivedMenuOption.unarchive: await unarchiveNote(context, ref, note: note, pop: true); + case EditorArchivedMenuOption.delete: + await deleteNote(context, ref, note: note, pop: true); case EditorArchivedMenuOption.about: await showAboutNote(); } @@ -221,6 +223,7 @@ class _BackAppBarState extends ConsumerState { EditorArchivedMenuOption.share.popupMenuItem(context), const PopupMenuDivider(), EditorArchivedMenuOption.unarchive.popupMenuItem(context), + EditorArchivedMenuOption.delete.popupMenuItem(context), const PopupMenuDivider(), EditorArchivedMenuOption.about.popupMenuItem(context), ]), diff --git a/lib/common/navigation/app_bars/selection/notes_selection_app_bar.dart b/lib/common/navigation/app_bars/selection/notes_selection_app_bar.dart index a41624d7..8caafe3b 100644 --- a/lib/common/navigation/app_bars/selection/notes_selection_app_bar.dart +++ b/lib/common/navigation/app_bars/selection/notes_selection_app_bar.dart @@ -74,6 +74,8 @@ class NotesSelectionAppBar extends ConsumerWidget { await shareNotes(context, notes: notes); case SelectionArchivedMenuOption.unarchive: await unarchiveNotes(context, ref, notes: notes); + case SelectionArchivedMenuOption.delete: + await deleteNotes(context, ref, notes: notes); } } @@ -136,6 +138,7 @@ class NotesSelectionAppBar extends ConsumerWidget { SelectionArchivedMenuOption.share.popupMenuItem(context), const PopupMenuDivider(), SelectionArchivedMenuOption.unarchive.popupMenuItem(context), + SelectionArchivedMenuOption.delete.popupMenuItem(context), ]), onSelected: (menuOption) => onArchivedMenuOptionSelected(context, ref, selectedNotes, menuOption), ), diff --git a/lib/common/navigation/enums/editor/editor_archived_menu_option.dart b/lib/common/navigation/enums/editor/editor_archived_menu_option.dart index 74b754ec..9b8b69d0 100644 --- a/lib/common/navigation/enums/editor/editor_archived_menu_option.dart +++ b/lib/common/navigation/enums/editor/editor_archived_menu_option.dart @@ -16,6 +16,9 @@ enum EditorArchivedMenuOption { /// Unarchive the note. unarchive(Icons.unarchive), + /// Delete the note. + delete(Icons.delete), + /// Show information about the note. about(Icons.info); @@ -36,6 +39,8 @@ enum EditorArchivedMenuOption { return context.l.menu_action_select_labels; case unarchive: return context.l.action_unarchive; + case delete: + return context.l.action_delete; case about: return context.l.action_about; } diff --git a/lib/common/navigation/enums/notes/selection_archived_menu_option.dart b/lib/common/navigation/enums/notes/selection_archived_menu_option.dart index 8cbe5bfe..8465cdca 100644 --- a/lib/common/navigation/enums/notes/selection_archived_menu_option.dart +++ b/lib/common/navigation/enums/notes/selection_archived_menu_option.dart @@ -11,7 +11,10 @@ enum SelectionArchivedMenuOption { share(Icons.share), /// Unarchive the note. - unarchive(Icons.unarchive); + unarchive(Icons.unarchive), + + /// Delete the notes. + delete(Icons.delete); /// Icon of the menu option. final IconData icon; @@ -30,6 +33,8 @@ enum SelectionArchivedMenuOption { return context.fl.shareButtonLabel; case unarchive: return context.l.action_unarchive; + case delete: + return context.l.action_delete; } } From d2e41ebf7ab7121fe90818905cad6eac92f484e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 01:44:40 +0000 Subject: [PATCH 2/2] fix(delete): move the archived notes back to the archives when undoing their deletion The deleted notes were archived again through the provider of the deleted notes, which only accepts the available and archived ones. Refs #595 Co-Authored-By: Claude --- lib/common/actions/notes/delete.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/common/actions/notes/delete.dart b/lib/common/actions/notes/delete.dart index 26b2bd26..25937d97 100644 --- a/lib/common/actions/notes/delete.dart +++ b/lib/common/actions/notes/delete.dart @@ -9,7 +9,6 @@ import '../../constants/constants.dart'; import '../../dialogs/confirmation_dialog.dart'; import '../../extensions/build_context_extension.dart'; import '../../ui/snack_bar_utils.dart'; -import 'archive.dart'; import 'restore.dart'; import 'select.dart'; @@ -50,7 +49,7 @@ Future deleteNote( context, text: context.l.snack_bar_deleted(1), onCancel: (globalRef) async => wasArchived - ? await archiveNote(rootNavigatorKey.currentContext!, globalRef, note: note, cancel: false) + ? await _restoreArchivedNotes(globalRef, [note]) : await restoreNote(rootNavigatorKey.currentContext!, globalRef, note: note, cancel: false), ); } @@ -86,7 +85,7 @@ Future deleteNotes(BuildContext context, WidgetRef ref, {required List wereArchived - ? await archiveNotes(rootNavigatorKey.currentContext!, globalRef, notes: notes, cancel: false) + ? await _restoreArchivedNotes(globalRef, notes) : await restoreNotes(rootNavigatorKey.currentContext!, globalRef, notes: notes, cancel: false), ); } @@ -94,6 +93,17 @@ Future deleteNotes(BuildContext context, WidgetRef ref, {required List _restoreArchivedNotes(WidgetRef ref, List notes) async { + if (!await ref.read(notesProvider(status: NoteStatus.deleted).notifier).setDeleted(notes, false)) { + return false; + } + + return ref.read(notesProvider(status: NoteStatus.available).notifier).setArchived(notes, true); +} + /// Permanently deletes the [note]. /// /// Returns `true` if the [note] was permanently deleted, `false` otherwise.