π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Properly update mmd
laurenspriem7f6d4027a5c7
diff --git a/mobile/lib/ui/components/bulk_edit_widget.dart b/mobile/lib/ui/components/bulk_edit_widget.dartindex 27d062c10d..9be65b7cab 100644--- a/mobile/lib/ui/components/bulk_edit_widget.dart+++ b/mobile/lib/ui/components/bulk_edit_widget.dart@@ -197,23 +197,30 @@ Future<DateTime> _editDates() async {if (firstDateForShift != null) {final firstDateDiff = newDate.difference(firstDateForShift);+ final filesToNewDates = <EnteFile, int>{};for (final file in enteFiles) {if (file.creationTime == null) {continue;}final fileTime = DateTime.fromMicrosecondsSinceEpoch(file.creationTime!);final newTime = fileTime.add(firstDateDiff);- await editTime(- context,- [file],- newTime.microsecondsSinceEpoch,- );+ filesToNewDates[file] = newTime.microsecondsSinceEpoch;}+ await editTime(+ context,+ filesToNewDates,+ );} else {+ final filesToNewDates = <EnteFile, int>{};+ for (final file in enteFiles) {+ if (file.creationTime == null) {+ continue;+ }+ filesToNewDates[file] = newDate.microsecondsSinceEpoch;+ }await editTime(context,- enteFiles.toList(),- newDate.microsecondsSinceEpoch,+ filesToNewDates,);}return newDate;diff --git a/mobile/lib/utils/magic_util.dart b/mobile/lib/utils/magic_util.dartindex 62411de438..ab8c49b522 100644--- a/mobile/lib/utils/magic_util.dart+++ b/mobile/lib/utils/magic_util.dart@@ -169,16 +169,13 @@ Future<void> changeCoverPhoto(Future<bool> editTime(BuildContext context,- List<EnteFile> files,- int editedTime,+ Map<EnteFile, int> filesToEditedTimes,) async {try {- await _updatePublicMetadata(- context,- files,- editTimeKey,- editedTime,+ final filesToKeyAndValue = filesToEditedTimes.map(+ (file, editedTime) => MapEntry(file, (editTimeKey, editedTime)),);+ await _bulkUpdatePublicMetadata(context, filesToKeyAndValue);return true;} catch (e) {showShortToast(context, S.of(context).somethingWentWrong);@@ -246,6 +243,62 @@ Future<bool> editFileCaption(}}+Future<void> _bulkUpdatePublicMetadata(+ BuildContext? context,+ Map<EnteFile, (String, dynamic)> filesToKeyAndValue, {+ bool showDoneToast = true,+ bool showProgressDialogs = true,+}) async {+ if (filesToKeyAndValue.isEmpty) {+ return;+ }+ ProgressDialog? dialog;+ if (context != null && showProgressDialogs) {+ dialog = createProgressDialog(context, S.of(context).pleaseWait);+ await dialog.show();+ }++ final Set<String> keys = {};+ final Map<(String, dynamic), List<EnteFile>> updateToFiles = {};+ for (final entry in filesToKeyAndValue.entries) {+ final file = entry.key;+ final update = entry.value;+ if (updateToFiles.containsKey(update)) {+ updateToFiles[update]!.add(file);+ } else {+ updateToFiles[update] = [file];+ }+ keys.add(update.$1);+ }+ try {+ for (final entry in updateToFiles.entries) {+ final update = entry.key;+ final files = entry.value;+ await FileMagicService.instance+ .updatePublicMagicMetadata(files, {update.$1: update.$2});+ }+ if (context != null) {+ if (showDoneToast) {+ showShortToast(context, S.of(context).done);+ }+ await dialog?.hide();+ }++ for (final String key in keys) {+ if (_shouldReloadGallery(key)) {+ Bus.instance+ .fire(ForceReloadHomeGalleryEvent("FileMetadataChange-$key"));+ }+ }+ } catch (e, s) {+ _logger.severe("failed to update one of ${updateToFiles.keys}", e, s);+ if (context != null) {+ await dialog?.hide();+ }+ rethrow;+ }+}+Future<void> _updatePublicMetadata(BuildContext? context,List<EnteFile> files,