mirror of
https://github.com/flarum/core.git
synced 2025-08-07 17:07:19 +02:00
Only pin to top if viewing a tag with no other filters
This commit is contained in:
@@ -49,24 +49,23 @@ class PinStickiedDiscussionsToTop
|
||||
// discussions to the top no matter what.
|
||||
$gambits = $search->getActiveGambits();
|
||||
|
||||
foreach ($gambits as $gambit) {
|
||||
if ($gambit instanceof TagGambit) {
|
||||
if ($count = count($gambits)) {
|
||||
if ($count === 1 && $gambits[0] instanceof TagGambit) {
|
||||
if (! is_array($query->orders)) {
|
||||
$query->orders = [];
|
||||
}
|
||||
|
||||
array_unshift($query->orders, ['column' => 'is_sticky', 'direction' => 'desc']);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, if we are viewing "all discussions", only pin stickied
|
||||
// discussions to the top if they are unread. To do this in a
|
||||
// performant way we create another query which will select all
|
||||
// stickied discussions, marry them into the main query, and then
|
||||
// reorder the unread ones up to the top.
|
||||
if (empty($gambits)) {
|
||||
$sticky = clone $query;
|
||||
$sticky->where('is_sticky', true);
|
||||
$sticky->orders = null;
|
||||
@@ -94,5 +93,4 @@ class PinStickiedDiscussionsToTop
|
||||
$query->offset = $sticky->offset = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user