cancellable file op: edit
This commit is contained in:
parent
ff11f9c842
commit
5e2731484e
2 changed files with 10 additions and 5 deletions
|
@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- moving or deleting multiple items can be cancelled
|
- moving, editing or deleting multiple items can be cancelled
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -420,14 +420,19 @@ class EntrySetActionDelegate with EntryEditorMixin, FeedbackMixin, PermissionAwa
|
||||||
|
|
||||||
final source = context.read<CollectionSource>();
|
final source = context.read<CollectionSource>();
|
||||||
source.pauseMonitoring();
|
source.pauseMonitoring();
|
||||||
|
var cancelled = false;
|
||||||
showOpReport<ImageOpEvent>(
|
showOpReport<ImageOpEvent>(
|
||||||
context: context,
|
context: context,
|
||||||
opStream: Stream.fromIterable(todoItems).asyncMap((entry) async {
|
opStream: Stream.fromIterable(todoItems).asyncMap((entry) async {
|
||||||
// TODO TLAD [cancel] allow cancelling edit op
|
if (cancelled) {
|
||||||
final dataTypes = await op(entry);
|
return ImageOpEvent(success: true, skipped: true, uri: entry.uri);
|
||||||
return ImageOpEvent(success: dataTypes.isNotEmpty, skipped: false, uri: entry.uri);
|
} else {
|
||||||
|
final dataTypes = await op(entry);
|
||||||
|
return ImageOpEvent(success: dataTypes.isNotEmpty, skipped: false, uri: entry.uri);
|
||||||
|
}
|
||||||
}).asBroadcastStream(),
|
}).asBroadcastStream(),
|
||||||
itemCount: todoCount,
|
itemCount: todoCount,
|
||||||
|
onCancel: () => cancelled = true,
|
||||||
onDone: (processed) async {
|
onDone: (processed) async {
|
||||||
final successOps = processed.where((e) => e.success).toSet();
|
final successOps = processed.where((e) => e.success).toSet();
|
||||||
final editedOps = successOps.where((e) => !e.skipped).toSet();
|
final editedOps = successOps.where((e) => !e.skipped).toSet();
|
||||||
|
@ -441,7 +446,7 @@ class EntrySetActionDelegate with EntryEditorMixin, FeedbackMixin, PermissionAwa
|
||||||
final count = todoCount - successCount;
|
final count = todoCount - successCount;
|
||||||
showFeedback(context, l10n.collectionEditFailureFeedback(count));
|
showFeedback(context, l10n.collectionEditFailureFeedback(count));
|
||||||
} else {
|
} else {
|
||||||
final count = successCount;
|
final count = editedOps.length;
|
||||||
showFeedback(context, l10n.collectionEditSuccessFeedback(count));
|
showFeedback(context, l10n.collectionEditSuccessFeedback(count));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue