Add support to search by uploader name
This commit is contained in:
@@ -26,6 +26,7 @@ import "package:photos/utils/share_util.dart";
|
||||
enum ResultType {
|
||||
collection,
|
||||
file,
|
||||
uploader,
|
||||
location,
|
||||
locationSuggestion,
|
||||
month,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user