Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Handle errors during album renaming and update album description validation

AmanRajSinghMourya3b0aca3a8ab3
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 49d3e9bddb..e4d95e247a 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -311,7 +311,14 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
onSave: (update) async {
try {
if (update.name != collection.displayName.trim()) {
- await CollectionsService.instance.rename(collection, update.name);
+ try {
+ await CollectionsService.instance.rename(collection, update.name);
+ } catch (_) {
+ if (context.mounted) {
+ showShortToast(context, context.strings.somethingWentWrong);
+ }
+ rethrow;
+ }
_appBarTitle = update.name;
}
if (update.description != (collection.displayDescription ?? "")) {
diff --git a/mobile/apps/photos/lib/utils/magic_util.dart b/mobile/apps/photos/lib/utils/magic_util.dart
index cd7d9dc59e..c09e5ca57d 100644
--- a/mobile/apps/photos/lib/utils/magic_util.dart
+++ b/mobile/apps/photos/lib/utils/magic_util.dart
@@ -209,17 +209,16 @@ Future<void> changeAlbumDescription(
String description,
) async {
final normalizedDescription = description.trim();
- if (normalizedDescription.length > maxAlbumDescriptionLength) {
- throw ArgumentError.value(
- description,
- "description",
- "Album descriptions cannot exceed $maxAlbumDescriptionLength characters",
- );
- }
-
try {
+ if (normalizedDescription.characters.length > maxAlbumDescriptionLength) {
+ throw ArgumentError.value(
+ description,
+ "description",
+ "Album descriptions cannot exceed $maxAlbumDescriptionLength characters",
+ );
+ }
await CollectionsService.instance.updatePublicMagicMetadata(collection, {
- "albumDescriptionKey": normalizedDescription,
+ albumDescriptionKey: normalizedDescription,
});
Bus.instance.fire(
CollectionUpdatedEvent(collection.id, <EnteFile>[], "description_change"),