Sorting changed to "created"

This commit is contained in:
Michael
2023-12-14 06:18:17 +00:00
parent eae1affb21
commit 1cd729531d
8 changed files with 48 additions and 22 deletions

View File

@@ -1298,6 +1298,8 @@ class Conversation
usort($parents, [$this, 'sortThrFeaturedReceived']);
} elseif (stristr($order, 'pinned_commented')) {
usort($parents, [$this, 'sortThrFeaturedCommented']);
} elseif (stristr($order, 'pinned_created')) {
usort($parents, [$this, 'sortThrFeaturedCreated']);
} elseif (stristr($order, 'received')) {
usort($parents, [$this, 'sortThrReceived']);
} elseif (stristr($order, 'commented')) {
@@ -1375,6 +1377,24 @@ class Conversation
return strcmp($b['commented'], $a['commented']);
}
/**
* usort() callback to sort item arrays by featured and the created key
*
* @param array $a
* @param array $b
* @return int
*/
private function sortThrFeaturedCreated(array $a, array $b): int
{
if ($b['featured'] && !$a['featured']) {
return 1;
} elseif (!$b['featured'] && $a['featured']) {
return -1;
}
return strcmp($b['created'], $a['created']);
}
/**
* usort() callback to sort item arrays by the received key
*