]> git.mxchange.org Git - friendica.git/commitdiff
getting comment counts correct in a threaded world
authorfriendica <info@friendica.com>
Sat, 11 Aug 2012 08:26:10 +0000 (01:26 -0700)
committerfriendica <info@friendica.com>
Sat, 11 Aug 2012 08:26:10 +0000 (01:26 -0700)
include/conversation.php

index e6f998a9d94a196a54c45b909fcb21a7f7e8f6d0..adc198412e2900380dccd7324aa9a1ec621fbbf7 100644 (file)
@@ -305,11 +305,11 @@ function localize_item(&$item){
 function count_descendants($item) {
        $total = count($item['children']);
 
-       if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE)
-               return 0;
-
        if($total > 0) {
                foreach($item['children'] as $child) {
+                       if($child['verb'] === ACTIVITY_LIKE || $child['verb'] === ACTIVITY_DISLIKE) {
+                               $total --;
+                       }
                        $total += count_descendants($child);
                }
        }
@@ -332,17 +332,25 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr
        $total_children = $nb_items;
        
        foreach($items as $item) {
-               // prevent private email reply to public conversation from leaking.
                if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
                        // Don't count it as a visible item
                        $nb_items--;
-                       $total_children = $nb_items;
+                       $total_children --;
+               }
+               if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) {
+                       $nb_items --;
+                       $total_children --;
+
+               }
+       }
+
+       foreach($items as $item) {
+               // prevent private email reply to public conversation from leaking.
+               if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
                        continue;
                }
 
                if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) {
-                       $nb_items --;
-                       $total_children = $nb_items;
                        continue;
                }