From 078441204db771dcb7d18d88ed153e34973aa81d Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 11 Apr 2021 22:29:20 -0400 Subject: [PATCH] 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. --- .../sticky/src/PinStickiedDiscussionsToTop.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/extensions/sticky/src/PinStickiedDiscussionsToTop.php b/extensions/sticky/src/PinStickiedDiscussionsToTop.php index 839a4dd76..93c31ee28 100755 --- a/extensions/sticky/src/PinStickiedDiscussionsToTop.php +++ b/extensions/sticky/src/PinStickiedDiscussionsToTop.php @@ -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