π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Add trip location names
laurenspriem2fd5c703c92a
diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dartindex 7a2fc0ebea..5267d4cb0a 100644--- a/mobile/lib/services/search_service.dart+++ b/mobile/lib/services/search_service.dart@@ -1498,8 +1498,11 @@ class SearchService {for (final trip in tripsToShow) {final year =DateTime.fromMicrosecondsSinceEpoch(trip.averageCreationTime).year;+ final String? locationName = await _tryFindLocationName(trip.files);String name = "Trip in $year!";- if (year == currentTime.year - 1) {+ if (locationName != null) {+ name = "Trip to $locationName!";+ } else if (year == currentTime.year - 1) {name = "Last year's trip!";}final photoSelection = await _bestSelection(trip.files);@@ -1546,8 +1549,11 @@ class SearchService {final year =DateTime.fromMicrosecondsSinceEpoch(trip.averageCreationTime).year;+ final String? locationName = await _tryFindLocationName(trip.files);String name = "Trip in $year!";- if (year == currentTime.year - 1) {+ if (locationName != null) {+ name = "Trip to $locationName!";+ } else if (year == currentTime.year - 1) {name = "Last year's trip!";}final photoSelection = await _bestSelection(trip.files);@@ -1843,6 +1849,22 @@ class SearchService {return ((dayOfYear - 1) ~/ 7) + 1;}+ Future<String?> _tryFindLocationName(List<EnteFile> files) async {+ final results = await locationService.getFilesInCity(files, '');+ final List<City> sortedByResultCount = results.keys.toList()+ ..sort((a, b) => results[b]!.length.compareTo(results[a]!.length));+ if (sortedByResultCount.isEmpty) return null;+ final biggestPlace = sortedByResultCount.first;+ if (results[biggestPlace]!.length > files.length / 2) {+ return biggestPlace.city;+ }+ if (results.length > 2 &&+ results.keys.map((city) => city.country).toSet().length == 1) {+ return biggestPlace.country;+ }+ return null;+ }+/// Returns the best selection of files from the given list./// Makes sure that the selection is not more than [prefferedSize] or 10 files,/// and that each year of the original list is represented.