]> git.mxchange.org Git - friendica.git/commitdiff
Issue-9358 (now for real) commenting and updating on contact now work
authorMichael <heluecht@pirati.ca>
Tue, 6 Oct 2020 18:47:23 +0000 (18:47 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 6 Oct 2020 18:47:23 +0000 (18:47 +0000)
include/conversation.php
mod/update_contact.php
src/Model/Contact.php
src/Module/Contact.php

index 1e8437f71532753752a354821ad55b7221936c1b..c2226fa352be293a3cfae2ecb8d8a440d319f418 100644 (file)
@@ -452,8 +452,8 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                $profile_owner = 0;
 
                if (!$update) {
-                       $live_update_div = '<div id="live-contacts"></div>' . "\r\n"
-                               . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
+                       $live_update_div = '<div id="live-contact"></div>' . "\r\n"
+                               . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 8)
                                ."/?f='; </script>\r\n";
                }
        } elseif ($mode === 'search') {
index 4863ad02ded5b4935c7bac1d631006fea691c775..3f8e00b296f9583ea4d3db4c3bc9dee7db2679ef 100644 (file)
@@ -28,11 +28,10 @@ use Friendica\Module\Contact;
 
 function update_contact_content(App $a)
 {
-       if (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) {
-               $text = Contact::content([], true);
+       if (!empty($a->argv[1]) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) {
+               $text = Contact::getConversationsHMTL($a, $a->argv[1], true, ($_GET['item'] ?? 0));
        } else {
                $text = '';
        }
-
        System::htmlUpdateExit($text);
 }
index e997bffdef95a5dee31c178b12cf57ab09a9ae28..41c68bda83ae60ad407db928bcafc5fe7b8c1301 100644 (file)
@@ -1248,12 +1248,13 @@ class Contact
         * @param string $contact_url Contact URL
         * @param bool   $thread_mode
         * @param int    $update
+        * @param int    $parent
         * @return string posts in HTML
         * @throws \Exception
         */
-       public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0)
+       public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0, $parent = 0)
        {
-               return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update);
+               return self::getPostsFromId(self::getIdForURL($contact_url), $thread_mode, $update, $parent);
        }
 
        /**
@@ -1262,10 +1263,11 @@ class Contact
         * @param integer $cid
         * @param bool    $thread_mode
         * @param integer $update
+        * @param int     $parent
         * @return string posts in HTML
         * @throws \Exception
         */
-       public static function getPostsFromId($cid, $thread_mode = false, $update = 0)
+       public static function getPostsFromId($cid, $thread_mode = false, $update = 0, $parent = 0)
        {
                $a = DI::app();
 
@@ -1290,9 +1292,13 @@ class Contact
                                $cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
                }
 
-               $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
-               if (!empty($last_received)) {
-                       $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
+               if (!empty($parent)) {
+                       $condition = DBA::mergeConditions($condition, ['parent' => $parent]);
+               } else {
+                       $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
+                       if (!empty($last_received)) {
+                               $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
+                       }
                }
 
                if (DI::mode()->isMobile()) {
@@ -1335,7 +1341,7 @@ class Contact
 
                        $items = Item::inArray($r);
 
-                       $o .= conversation($a, $items, 'contact-posts', false);
+                       $o .= conversation($a, $items, 'contact-posts', $update);
                }
 
                if (!$update) {
index 659380fbef3ba7bf3a08197bc923ff038fcdf2de..cc4f4d9abedda01c6bca64dfee34eb96dff3c7fc 100644 (file)
@@ -921,7 +921,7 @@ class Contact extends BaseModule
                return $tab_str;
        }
 
-       private static function getConversationsHMTL($a, $contact_id, $update)
+       public static function getConversationsHMTL($a, $contact_id, $update, $parent = 0)
        {
                $o = '';
 
@@ -952,14 +952,15 @@ class Contact extends BaseModule
                if (DBA::isResult($contact)) {
                        DI::page()['aside'] = '';
 
-                       $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user());
-
-                       Model\Profile::load($a, '', $profiledata, true);
+                       if (!$update) {
+                               $profiledata = Model\Contact::getByURLForUser($contact['url'], local_user());
+                               Model\Profile::load($a, '', $profiledata, true);
+                       }
 
                        if ($contact['uid'] == 0) {
-                               $o .= Model\Contact::getPostsFromId($contact['id'], true, $update);
+                               $o .= Model\Contact::getPostsFromId($contact['id'], true, $update, $parent);
                        } else {
-                               $o .= Model\Contact::getPostsFromUrl($contact['url'], true, $update);
+                               $o .= Model\Contact::getPostsFromUrl($contact['url'], true, $update, $parent);
                        }
                }