Skip to content

armgit / ente

Public Imported from GitHub
0

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

Constrain year search queries

ashil-pilotf9380de9d7b7
diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_query_utils.dart b/mobile/apps/photos/lib/ui/viewer/search/search_query_utils.dart
index 7e344f2f8b..a3587f1dcd 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/search_query_utils.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/search_query_utils.dart
@@ -1,6 +1,13 @@
import "package:ente_pure_utils/ente_pure_utils.dart";
+const _minimumSearchYear = 1900;
+
bool isYearSearchQuery(String query) {
+ if (query.length != 4) {
+ return false;
+ }
final yearAsInt = int.tryParse(query);
- return yearAsInt != null && yearAsInt <= currentYear;
+ return yearAsInt != null &&
+ yearAsInt >= _minimumSearchYear &&
+ yearAsInt <= currentYear;
}