Skip to content

Unified search: Files provider adds favorite state#58980

Open
tobiasKaminsky wants to merge 1 commit intomasterfrom
unifiedSearch/addFavoriteState
Open

Unified search: Files provider adds favorite state#58980
tobiasKaminsky wants to merge 1 commit intomasterfrom
unifiedSearch/addFavoriteState

Conversation

@tobiasKaminsky
Copy link
Member

  • Resolves: #

Summary

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@tobiasKaminsky tobiasKaminsky requested a review from a team as a code owner March 16, 2026 14:18
@tobiasKaminsky tobiasKaminsky requested review from ArtificialOwl, come-nc, icewind1991 and sorbaugh and removed request for a team March 16, 2026 14:18
@tobiasKaminsky
Copy link
Member Author

This is c&p from CollectionPhoto.php:76
I am too unexperienced to understand if I could somehow do this smarter.

);
}

private function isFavorite(string $fileId): bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private function isFavorite(string $fileId): bool {
private function isFavorite(int $fileId): bool {

);
$searchResultEntry->addAttribute('fileId', (string)$result->getId());
$searchResultEntry->addAttribute('path', $path);
$searchResultEntry->addAttribute('favorite', $this->isFavorite((string)$result->getId()) ? "true" : "false");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$searchResultEntry->addAttribute('favorite', $this->isFavorite((string)$result->getId()) ? "true" : "false");
$searchResultEntry->addAttribute('favorite', $this->isFavorite($result->getId()) ? "true" : "false");

}

private function isFavorite(string $fileId): bool {
$tagManager = \OCP\Server::get(\OCP\ITagManager::class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be injected in the constructor instead.

}
$tags = $tagger->getTagsForObjects([$fileId]);

if ($tags === false || empty($tags)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($tags === false || empty($tags)) {
if ($tags === false || empty($tags[$fileId])) {

return false;
}

return array_search(ITags::TAG_FAVORITE, current($tags)) !== false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return array_search(ITags::TAG_FAVORITE, current($tags)) !== false;
return array_search(ITags::TAG_FAVORITE, $tags[$fileId]) !== false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants