diff --git a/CHANGELOG.md b/CHANGELOG.md index 1810b056b..5b99f0976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file. ### Added -- moving or deleting multiple items can be cancelled +- moving, editing or deleting multiple items can be cancelled ### Changed diff --git a/lib/widgets/collection/entry_set_action_delegate.dart b/lib/widgets/collection/entry_set_action_delegate.dart index 6dcebe9c4..bda341314 100644 --- a/lib/widgets/collection/entry_set_action_delegate.dart +++ b/lib/widgets/collection/entry_set_action_delegate.dart @@ -420,14 +420,19 @@ class EntrySetActionDelegate with EntryEditorMixin, FeedbackMixin, PermissionAwa final source = context.read(); source.pauseMonitoring(); + var cancelled = false; showOpReport( context: context, opStream: Stream.fromIterable(todoItems).asyncMap((entry) async { - // TODO TLAD [cancel] allow cancelling edit op - final dataTypes = await op(entry); - return ImageOpEvent(success: dataTypes.isNotEmpty, skipped: false, uri: entry.uri); + if (cancelled) { + return ImageOpEvent(success: true, skipped: true, uri: entry.uri); + } else { + final dataTypes = await op(entry); + return ImageOpEvent(success: dataTypes.isNotEmpty, skipped: false, uri: entry.uri); + } }).asBroadcastStream(), itemCount: todoCount, + onCancel: () => cancelled = true, onDone: (processed) async { final successOps = processed.where((e) => e.success).toSet(); final editedOps = successOps.where((e) => !e.skipped).toSet(); @@ -441,7 +446,7 @@ class EntrySetActionDelegate with EntryEditorMixin, FeedbackMixin, PermissionAwa final count = todoCount - successCount; showFeedback(context, l10n.collectionEditFailureFeedback(count)); } else { - final count = successCount; + final count = editedOps.length; showFeedback(context, l10n.collectionEditSuccessFeedback(count)); } },