Added autohiding disliked posts to post searching
This commit is contained in:
parent
0e59147423
commit
b4992926a1
2 changed files with 14 additions and 3 deletions
1
TODO
1
TODO
|
@ -5,7 +5,6 @@ everything related to posts:
|
|||
- post listing
|
||||
- better thumbnail loading
|
||||
- comment count
|
||||
- regard disliked settings
|
||||
- search filters
|
||||
- comment:rr-
|
||||
- comment_count: 3..5
|
||||
|
|
|
@ -158,11 +158,12 @@ final class PostController extends AbstractController
|
|||
|
||||
private function decorateFilterFromBrowsingSettings($filter)
|
||||
{
|
||||
$userSettings = $this->authService->getLoggedInUser()->getBrowsingSettings();
|
||||
$currentUser = $this->authService->getLoggedInUser();
|
||||
$userSettings = $currentUser->getBrowsingSettings();
|
||||
if (!$userSettings)
|
||||
return;
|
||||
|
||||
if ($userSettings->listPosts and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_SAFETY)))
|
||||
if (!empty($userSettings->listPosts) and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_SAFETY)))
|
||||
{
|
||||
$values = [];
|
||||
if (!\Szurubooru\Helpers\TypeHelper::toBool($userSettings->listPosts->safe))
|
||||
|
@ -182,5 +183,16 @@ final class PostController extends AbstractController
|
|||
$filter->addRequirement($requirement);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($userSettings->hideDownvoted) and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_USER_SCORE)))
|
||||
{
|
||||
$requirementValue = new \Szurubooru\SearchServices\Requirements\RequirementCompositeValue();
|
||||
$requirementValue->setValues([$currentUser->getName(), -1]);
|
||||
$requirement = new \Szurubooru\SearchServices\Requirements\Requirement();
|
||||
$requirement->setType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_USER_SCORE);
|
||||
$requirement->setValue($requirementValue);
|
||||
$requirement->setNegated(true);
|
||||
$filter->addRequirement($requirement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue