Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix bug in getAllFileTypesAndExtensionsResults

ashilkn97dd621d67f5
diff --git a/lib/models/search/search_types.dart b/lib/models/search/search_types.dart
index 3f4fdc1a88..d6bf5ebe84 100644
--- a/lib/models/search/search_types.dart
+++ b/lib/models/search/search_types.dart
@@ -181,7 +181,8 @@ extension SectionTypeExtensions on SectionType {
return SearchService.instance.getAllCollectionSearchResults(limit);
case SectionType.fileTypesAndExtension:
- return SearchService.instance.getAllFileTypesAndExtensionsResults(null);
+ return SearchService.instance
+ .getAllFileTypesAndExtensionsResults(limit);
case SectionType.fileCaption:
return SearchService.instance.getAllDescriptionSearchResults(limit);
diff --git a/lib/services/search_service.dart b/lib/services/search_service.dart
index 4414f81208..b15e2c3056 100644
--- a/lib/services/search_service.dart
+++ b/lib/services/search_service.dart
@@ -194,12 +194,13 @@ class SearchService {
final fileTypesAndMatchingFiles = <FileType, List<EnteFile>>{};
final extensionsAndMatchingFiles = <String, List<EnteFile>>{};
- int i = 0;
+ int count = 0;
for (EnteFile file in allFiles) {
- if (limit != null && i++ <= limit) break;
+ if (limit != null && count >= limit) break;
if (!fileTypesAndMatchingFiles.containsKey(file.fileType)) {
fileTypesAndMatchingFiles[file.fileType] = <EnteFile>[];
+ count++;
}
fileTypesAndMatchingFiles[file.fileType]!.add(file);
@@ -212,6 +213,7 @@ class SearchService {
if (ext != "") {
if (!extensionsAndMatchingFiles.containsKey(ext)) {
extensionsAndMatchingFiles[ext] = <EnteFile>[];
+ count++;
}
extensionsAndMatchingFiles[ext]!.add(file);
}