From d4b61883568b9d8271e1960f3a4a15a5413284be Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 11 Aug 2012 01:26:10 -0700 Subject: [PATCH] getting comment counts correct in a threaded world --- include/conversation.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index e6f998a9d9..adc198412e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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; } -- 2.39.5