]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #13510 from annando/fix-thread-parent
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 7 Oct 2023 09:22:40 +0000 (05:22 -0400)
committerGitHub <noreply@github.com>
Sat, 7 Oct 2023 09:22:40 +0000 (05:22 -0400)
Fix for the display of the thread parent

1  2 
src/Object/Post.php

diff --combined src/Object/Post.php
index c5a4be9d780bcadca093e4ecdcadfbd74566e8fe,9240079fb76f9861c047f31f1a346c3905b1bbd7..4df953cab6b608a4f00e2460f9296d162e0f4c46
@@@ -156,15 -156,16 +156,16 @@@ class Pos
        /**
         * Get data in a form usable by a conversation template
         *
-        * @param array   $conv_responses conversation responses
-        * @param string $formSecurityToken A security Token to avoid CSF attacks
-        * @param integer $thread_level   default = 1
+        * @param array   $conv_responses    conversation responses
+        * @param string  $formSecurityToken A security Token to avoid CSF attacks
+        * @param integer $thread_level      default = 1
+        * @param array   $thread_parent     Array of parent guid and parent author names
         *
         * @return mixed The data requested on success, false on failure
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1, string $parent_guid = "", string $parent_username = "")
+       public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1, array $thread_parent = [])
        {
                $item = $this->getData();
                $edited = false;
                        $browsershare = null;
                }
  
+               $parent_guid     = $thread_parent[$item['thr-parent-id']]['guid'] ?? '';
+               $parent_username = $thread_parent[$item['thr-parent-id']]['name'] ?? '';
                $tmp_item = [
                        'parentguid'      => $parent_guid,
 -                      'isreplyto'       => DI::l10n()->t('is reply to %s', $parent_username),
 +                      'isreplyto'       => DI::l10n()->t('in reply to %s', $parent_username),
                        'template'        => $this->getTemplate(),
                        'type'            => implode('', array_slice(explode('/', $item['verb']), -1)),
                        'comment_firstcollapsed' => false,
                $children = $this->getChildren();
                $nb_children = count($children);
                if ($nb_children > 0) {
+                       $thread_parent[$item['uri-id']] = ['guid' => $item['guid'], 'name' => $item['author-name']];
                        foreach ($children as $child) {
-                               $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1, $tmp_item['guid'], $tmp_item['name']);
+                               $thread_parent[$child->getDataValue('uri-id')] = ['guid' => $child->getDataValue('guid'), 'name' => $child->getDataValue('author-name')];
+                               $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1, $thread_parent);
                        }
  
                        // Collapse