mirror of
https://github.com/nextcloud/server.git
synced 2026-03-29 13:53:55 -04:00
fix(TagSearchProvider): Short circuit if no tag matches the query
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
51fda57d59
commit
cfe21648d6
1 changed files with 6 additions and 4 deletions
|
|
@ -113,6 +113,11 @@ class TagSearchProvider implements IProvider {
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function search(IUser $user, ISearchQuery $query): SearchResult {
|
||||
$matchingTags = $this->tagManager->getAllTags(1, $query->getTerm());
|
||||
if (count($matchingTags) === 0) {
|
||||
return SearchResult::complete($this->l10n->t('Tags'), []);
|
||||
}
|
||||
|
||||
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
|
||||
$fileQuery = new SearchQuery(
|
||||
new SearchBinaryOperator(SearchBinaryOperator::OPERATOR_OR, [
|
||||
|
|
@ -133,7 +138,6 @@ class TagSearchProvider implements IProvider {
|
|||
return $node->getId();
|
||||
}, $searchResults);
|
||||
$matchedTags = $this->objectMapper->getTagIdsForObjects($resultIds, 'files');
|
||||
$relevantTags = $this->tagManager->getTagsByIds(array_unique($this->flattenArray($matchedTags)));
|
||||
|
||||
// prepare direct tag results
|
||||
$tagResults = array_map(function(ISystemTag $tag) {
|
||||
|
|
@ -149,9 +153,7 @@ class TagSearchProvider implements IProvider {
|
|||
'icon-tag'
|
||||
);
|
||||
return $searchResultEntry;
|
||||
}, array_filter($relevantTags, function($tag) use ($query) {
|
||||
return $tag->isUserVisible() && strpos($tag->getName(), $query->getTerm()) !== false;
|
||||
}));
|
||||
}, $matchingTags);
|
||||
|
||||
// prepare files results
|
||||
return SearchResult::paginated(
|
||||
|
|
|
|||
Loading…
Reference in a new issue