]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Speed improvement
[friendica.git] / include / conversation.php
index 1c9c37d24a7c872d9a0ca2f06c477c55d505f05e..faee8f5b3e8881b054a8f8941ffc689093ffb387 100644 (file)
@@ -708,17 +708,44 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
  */
 function conversation_fetch_comments($thread_items, $pinned) {
        $comments = [];
+       $parentlines = [];
+       $lineno = 0;
+       $direction = [];
+       $received = '';
 
        while ($row = Item::fetch($thread_items)) {
+               if (!empty($parentlines) && ($row['verb'] == Activity::ANNOUNCE)
+                       && ($row['thr-parent'] == $row['parent-uri']) && ($row['received'] > $received)
+                       && Contact::isSharing($row['author-id'], $row['uid'])) {
+                       $direction = ['direction' => 3, 'title' => DI::l10n()->t('%s reshared this.', $row['author-name'])];
+                       $received = $row['received'];
+               }
+
+               if (!empty($parentlines) && empty($direction) && ($row['gravity'] == GRAVITY_COMMENT)
+                       && Contact::isSharing($row['author-id'], $row['uid'])) {
+                       $direction = ['direction' => 2, 'title' => DI::l10n()->t('%s commented this.', $row['author-name'])];
+               }
+
+               if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id'])
+                       && !Contact::isSharing($row['author-id'], $row['uid'])) {
+                       $parentlines[] = $lineno;
+               }
+
                if ($row['gravity'] == GRAVITY_PARENT) {
                        $row['pinned'] = $pinned;
                }
 
                $comments[] = $row;
+               $lineno++;
        }
 
        DBA::close($thread_items);
 
+       if (!empty($direction)) {
+               foreach ($parentlines as $line) {
+                       $comments[$line]['direction'] = $direction;
+               }
+       }
        return $comments;
 }