diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e681d487..2fc550140 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
### Added
+- Viewer: prompt to show newly edited item
- Catalan translation (thanks Marc AmorĂ³s)
## [v1.10.4] - 2024-02-07
diff --git a/lib/widgets/viewer/action/entry_action_delegate.dart b/lib/widgets/viewer/action/entry_action_delegate.dart
index c9bb0941e..495575421 100644
--- a/lib/widgets/viewer/action/entry_action_delegate.dart
+++ b/lib/widgets/viewer/action/entry_action_delegate.dart
@@ -16,6 +16,7 @@ import 'package:aves/model/source/collection_source.dart';
import 'package:aves/model/vaults/vaults.dart';
import 'package:aves/services/common/services.dart';
import 'package:aves/theme/durations.dart';
+import 'package:aves/widgets/collection/collection_page.dart';
import 'package:aves/widgets/common/action_mixins/entry_storage.dart';
import 'package:aves/widgets/common/action_mixins/feedback.dart';
import 'package:aves/widgets/common/action_mixins/permission_aware.dart';
@@ -242,15 +243,14 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
).dispatch(context);
}
case EntryAction.edit:
- appService.edit(targetEntry.uri, targetEntry.mimeType).then((fields) {
+ appService.edit(targetEntry.uri, targetEntry.mimeType).then((fields) async {
final error = fields['error'] as String?;
if (error == null) {
- final uri = fields['uri'] as String?;
- if (uri != null) {
- debugPrint('TLAD uri=$uri');
- }
+ final resultUri = fields['uri'] as String?;
+ final mimeType = fields['mimeType'] as String?;
+ await _handleEditResult(context, resultUri, mimeType);
} else if (error == 'edit-resolve') {
- showNoMatchingAppDialog(context);
+ await showNoMatchingAppDialog(context);
}
});
case EntryAction.open:
@@ -288,6 +288,42 @@ class EntryActionDelegate with FeedbackMixin, PermissionAwareMixin, SizeAwareMix
}
}
+ Future _handleEditResult(BuildContext context, String? resultUri, String? mimeType) async {
+ final _collection = collection;
+ if (_collection == null || resultUri == null) return;
+
+ final editedEntry = await mediaFetchService.getEntry(resultUri, mimeType);
+ if (editedEntry == null) return;
+
+ final editedUri = editedEntry.uri;
+ final matchCurrentFilters = _collection.filters.every((filter) => filter.test(editedEntry));
+
+ final l10n = context.l10n;
+ // get navigator beforehand because
+ // local context may be deactivated when action is triggered after navigation
+ final navigator = Navigator.maybeOf(context);
+ final showAction = SnackBarAction(
+ label: l10n.showButtonLabel,
+ onPressed: () {
+ if (navigator != null) {
+ final source = _collection.source;
+ navigator.pushAndRemoveUntil(
+ MaterialPageRoute(
+ settings: const RouteSettings(name: CollectionPage.routeName),
+ builder: (context) => CollectionPage(
+ source: source,
+ filters: matchCurrentFilters ? _collection.filters : {},
+ highlightTest: (entry) => entry.uri == editedUri,
+ ),
+ ),
+ (route) => false,
+ );
+ }
+ },
+ );
+ showFeedback(context, FeedbackType.info, l10n.genericSuccessFeedback, showAction);
+ }
+
Future quickMove(BuildContext context, String album, {required bool copy}) async {
if (!await unlockAlbum(context, album)) return;