π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
wrote service method to update location data
ashilkne2f9ce717a00
diff --git a/lib/services/files_service.dart b/lib/services/files_service.dartindex d97b8a25e5..8f3869d925 100644--- a/lib/services/files_service.dart+++ b/lib/services/files_service.dart@@ -1,4 +1,5 @@import 'package:dio/dio.dart';+import "package:latlong2/latlong.dart";import 'package:logging/logging.dart';import 'package:path/path.dart';import 'package:photos/core/configuration.dart';@@ -85,6 +86,38 @@ class FilesService {}}+ Future<void> bulkEditLocationData(+ List<EnteFile> files,+ LatLng location,+ ) async {+ final List<EnteFile> uploadedFiles =+ files.where((element) => element.uploadedFileID != null).toList();++ final List<EnteFile> remoteFilesToUpdate = [];+ final Map<int, Map<String, dynamic>> fileIDToUpdateMetadata = {};+ for (EnteFile remoteFile in uploadedFiles) {+ // discard files not owned by user and also dedupe already processed+ // files+ if (remoteFile.ownerID != _config.getUserID()! ||+ fileIDToUpdateMetadata.containsKey(remoteFile.uploadedFileID!)) {+ continue;+ }++ remoteFilesToUpdate.add(remoteFile);+ fileIDToUpdateMetadata[remoteFile.uploadedFileID!] = {+ latKey: location.latitude,+ longKey: location.longitude,+ };+ }+ if (remoteFilesToUpdate.isNotEmpty) {+ await FileMagicService.instance.updatePublicMagicMetadata(+ remoteFilesToUpdate,+ null,+ metadataUpdateMap: fileIDToUpdateMetadata,+ );+ }+ }+// Note: this method is not used anywhere, but it is kept for future// reference when we add bulk EditTime featureFuture<void> bulkEditTime(diff --git a/lib/ui/viewer/location/update_location_data_widget.dart b/lib/ui/viewer/location/update_location_data_widget.dartindex fe2377625c..1a33ceab18 100644--- a/lib/ui/viewer/location/update_location_data_widget.dart+++ b/lib/ui/viewer/location/update_location_data_widget.dart@@ -2,6 +2,7 @@ import "package:flutter/material.dart";import "package:flutter_map/flutter_map.dart";import "package:latlong2/latlong.dart";import "package:photos/models/file/file.dart";+import "package:photos/services/files_service.dart";import "package:photos/ui/map/map_button.dart";import "package:photos/ui/map/tile/layers.dart";@@ -71,7 +72,10 @@ class _UpdateLocationDataWidgetState extends State<UpdateLocationDataWidget> {// icon: Icons.add_location_alt_outlined,icon: Icons.check,- onPressed: () {},+ onPressed: () async {+ await FilesService.instance+ .bulkEditLocationData(widget.files, selectedLocation!);+ },heroTag: 'add-location',),const SizedBox(height: 16),