π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Avoid unnecessary location search work
Neeraj Gupta01b34547773c
diff --git a/mobile/apps/photos/lib/services/location_service.dart b/mobile/apps/photos/lib/services/location_service.dartindex 776414a647..32782c480f 100644--- a/mobile/apps/photos/lib/services/location_service.dart+++ b/mobile/apps/photos/lib/services/location_service.dart@@ -113,6 +113,16 @@ class LocationService {}final EnteWatch w = EnteWatch("cities_search")..start();w.log('start for files ${allFiles.length} and query $query');+ final normalizedQuery = query.toLowerCase();+ if (normalizedQuery.isNotEmpty &&+ !_citySearchIndex.cities.any(+ (city) => city.city.toLowerCase().contains(normalizedQuery),+ )) {+ w.log(+ 'end for query: $query on ${allFiles.length} files, found 0 cities',+ );+ return {};+ }final args = _citySearchIndex.searchArgs(allFiles, query: query);final result = await _computer.compute(getCityResults, param: args);w.log(diff --git a/mobile/apps/photos/lib/services/search_service.dart b/mobile/apps/photos/lib/services/search_service.dartindex 145fd1eb6d..8dd194fba0 100644--- a/mobile/apps/photos/lib/services/search_service.dart+++ b/mobile/apps/photos/lib/services/search_service.dart@@ -994,8 +994,10 @@ class SearchService {}}final allFiles = await getAllFilesForSearch();+ final filesWithLocation = <EnteFile>[];for (EnteFile file in allFiles) {if (file.hasLocation) {+ filesWithLocation.add(file);for (LocalEntity<LocationTag> tag in result.keys) {if (isFileInsideLocationTag(tag.item.centerPoint,@@ -1030,10 +1032,7 @@ class SearchService {}if (showNoLocationTag) {_logger.info("finding photos with no location tag");- final noLocationTagFiles = allFiles.where((file) {- if (!file.hasLocation) {- return false;- }+ final noLocationTagFiles = filesWithLocation.where((file) {for (LocalEntity<LocationTag> tag in locationTagEntities) {if (isFileInsideLocationTag(tag.item.centerPoint,@@ -1094,7 +1093,10 @@ class SearchService {if (allCitiesSearch) {query = '';}- final results = await locationService.getFilesInCity(allFiles, query);+ final results = await locationService.getFilesInCity(+ filesWithLocation,+ query,+ );final List<City> sortedByResultCount = results.keys.toList()..sort((a, b) => results[b]!.length.compareTo(results[a]!.length));for (final city in sortedByResultCount) {