mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 16:33:00 +08:00
Use criteria's sortIsDefault field
This was introduced in https://github.com/flarum/core/pull/2773, and allows us to more cleanly determine whether the sort requested is the default one, while taking extension modifications into account.
This commit is contained in:
parent
4805b7d2ee
commit
078441204d
|
@ -16,22 +16,9 @@ use Flarum\Tags\Query\TagFilterGambit;
|
|||
|
||||
class PinStickiedDiscussionsToTop
|
||||
{
|
||||
/**
|
||||
* Used to get the default sort.
|
||||
*
|
||||
* @var ListDiscussionsController
|
||||
*/
|
||||
protected $listDiscussionsController;
|
||||
|
||||
public function __construct(ListDiscussionsController $listDiscussionsController)
|
||||
{
|
||||
$this->listDiscussionsController = $listDiscussionsController;
|
||||
}
|
||||
|
||||
public function __invoke(FilterState $filterState, QueryCriteria $criteria)
|
||||
{
|
||||
// TODO: This should take modifications by extensions into account.
|
||||
if ($criteria->sort == $this->listDiscussionsController->sort) {
|
||||
if ($criteria->sortIsDefault) {
|
||||
$query = $filterState->getQuery();
|
||||
|
||||
// If we are viewing a specific tag, then pin all stickied
|
||||
|
|
Loading…
Reference in New Issue
Block a user