Add support to search by uploader name

This commit is contained in:
Neeraj Gupta
2025-03-26 22:16:11 +05:30
parent 90bf99c20b
commit 4500a8f620
2 changed files with 21 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import "package:photos/utils/share_util.dart";
enum ResultType {
collection,
file,
uploader,
location,
locationSuggestion,
month,

View File

@@ -551,6 +551,7 @@ class SearchService {
final List<EnteFile> allFiles = await getAllFilesForSearch();
final List<EnteFile> captionMatch = <EnteFile>[];
final List<EnteFile> displayNameMatch = <EnteFile>[];
final List<EnteFile> uploaderNameMatch = <EnteFile>[];
for (EnteFile eachFile in allFiles) {
if (eachFile.caption != null && pattern.hasMatch(eachFile.caption!)) {
captionMatch.add(eachFile);
@@ -558,6 +559,10 @@ class SearchService {
if (pattern.hasMatch(eachFile.displayName)) {
displayNameMatch.add(eachFile);
}
if (eachFile.uploaderName != null &&
pattern.hasMatch(eachFile.uploaderName!)) {
uploaderNameMatch.add(eachFile);
}
}
if (captionMatch.isNotEmpty) {
searchResults.add(
@@ -590,6 +595,21 @@ class SearchService {
),
);
}
if (uploaderNameMatch.isNotEmpty) {
searchResults.add(
GenericSearchResult(
ResultType.uploader,
query,
uploaderNameMatch,
hierarchicalSearchFilter: TopLevelGenericFilter(
filterName: query,
occurrence: kMostRelevantFilter,
filterResultType: ResultType.uploader,
matchedUploadedIDs: filesToUploadedFileIDs(uploaderNameMatch),
),
),
);
}
return searchResults;
}