Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix

AmanRajSinghMourya35b530df7a22
diff --git a/mobile/apps/locker/lib/utils/file_actions.dart b/mobile/apps/locker/lib/utils/file_actions.dart
index 21d7ddbf9c..37e4041f1b 100644
--- a/mobile/apps/locker/lib/utils/file_actions.dart
+++ b/mobile/apps/locker/lib/utils/file_actions.dart
@@ -7,6 +7,7 @@ import "package:locker/services/collections/collections_service.dart";
import "package:locker/services/collections/models/collection.dart";
import "package:locker/services/favorites_service.dart";
import "package:locker/services/files/links/links_service.dart";
+import "package:locker/services/files/sync/metadata_updater_service.dart";
import "package:locker/services/files/sync/models/file.dart";
import "package:locker/services/trash/trash_service.dart";
import "package:locker/ui/components/delete_confirmation_dialog.dart";
@@ -18,7 +19,7 @@ import "package:logging/logging.dart";
class FileActions {
static final _logger = Logger("FileActions");
- /// Shows edit dialog for a file to update its collections
+ /// Shows edit dialog for a file to update title, caption, and collections
static Future<void> editFile(
BuildContext context,
EnteFile file, {
@@ -59,6 +60,28 @@ class FileActions {
await dialog.show();
try {
+ final currentTitle = file.displayName;
+ final currentCaption = file.caption ?? '';
+ final hasMetadataChanged =
+ result.title != currentTitle || result.caption != currentCaption;
+
+ if (hasMetadataChanged) {
+ _logger.info('Updating file metadata: title and/or caption changed');
+ final metadataUpdateSuccess = await MetadataUpdaterService.instance
+ .editFileNameAndCaption(file, result.title, result.caption);
+
+ if (!metadataUpdateSuccess) {
+ await dialog.hide();
+ if (!context.mounted) {
+ return;
+ }
+ showToast(
+ context,
+ context.l10n.failedToUpdateFile('Metadata update failed'),
+ );
+ return;
+ }
+ }
final selectedCollectionIds =
result.selectedCollections.map((c) => c.id).toSet();
@@ -137,7 +160,12 @@ class FileActions {
if (!context.mounted) {
return;
}
- showToast(context, context.l10n.fileUpdatedSuccessfully);
+
+ if (hasMetadataChanged) {
+ showToast(context, context.l10n.fileUpdatedSuccessfully);
+ } else {
+ showToast(context, context.l10n.fileUpdatedSuccessfully);
+ }
onSuccess?.call();
} catch (e) {