]> git.mxchange.org Git - friendica.git/commitdiff
Only sort the profile after pinned
authorMichael <heluecht@pirati.ca>
Thu, 7 Nov 2019 07:39:50 +0000 (07:39 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 7 Nov 2019 07:39:50 +0000 (07:39 +0000)
include/conversation.php
src/Module/Profile.php

index 54008fb5d4304c078f333ee0f58194c0726ff652..f6da5d858a963e3ade605ab3a8622988542ddcf3 100644 (file)
@@ -1451,7 +1451,9 @@ function conv_sort(array $item_list, $order)
                }
        }
 
-       if (stristr($order, 'received')) {
+       if (stristr($order, 'pinned_received')) {
+               usort($parents, 'sort_thr_pinned_received');
+       } elseif (stristr($order, 'received')) {
                usort($parents, 'sort_thr_received');
        } elseif (stristr($order, 'commented')) {
                usort($parents, 'sort_thr_commented');
@@ -1489,13 +1491,13 @@ function conv_sort(array $item_list, $order)
 }
 
 /**
- * @brief usort() callback to sort item arrays by the received key
+ * @brief usort() callback to sort item arrays by pinned and the received key
  *
  * @param array $a
  * @param array $b
  * @return int
  */
-function sort_thr_received(array $a, array $b)
+function sort_thr_pinned_received(array $a, array $b)
 {
        if ($b['pinned'] && !$a['pinned']) {
                return 1;
@@ -1506,6 +1508,18 @@ function sort_thr_received(array $a, array $b)
        return strcmp($b['received'], $a['received']);
 }
 
+/**
+ * @brief usort() callback to sort item arrays by the received key
+ *
+ * @param array $a
+ * @param array $b
+ * @return int
+ */
+function sort_thr_received(array $a, array $b)
+{
+       return strcmp($b['received'], $a['received']);
+}
+
 /**
  * @brief usort() callback to reverse sort item arrays by the received key
  *
@@ -1515,12 +1529,6 @@ function sort_thr_received(array $a, array $b)
  */
 function sort_thr_received_rev(array $a, array $b)
 {
-       if ($b['pinned'] && !$a['pinned']) {
-               return -1;
-       } elseif (!$b['pinned'] && $a['pinned']) {
-               return 1;
-       }
-
        return strcmp($a['received'], $b['received']);
 }
 
index ac345fad243047ba589e9bf944263d8b6c262f8e..cd0ee66bb95ef871c9a4d624806a84f7ca21ebb4 100644 (file)
@@ -355,7 +355,7 @@ class Profile extends BaseModule
                        $items = array_merge($items, $pinned);
                }
 
-               $o .= conversation($a, $items, $pager, 'profile', $update, false, 'received', $a->profile['profile_uid']);
+               $o .= conversation($a, $items, $pager, 'profile', $update, false, 'pinned_received', $a->profile['profile_uid']);
 
                if (!$update) {
                        $o .= $pager->renderMinimal(count($items));