diff --git a/include/conversation.php b/include/conversation.php index 370796257..d77e3b2f9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -460,7 +460,6 @@ function conv_get_blocklist() * that are based on unique features of the calling module. * @param App $a * @param array $items - * @param Pager $pager * @param $mode * @param $update * @param bool $preview @@ -470,7 +469,7 @@ function conv_get_blocklist() * @throws ImagickException * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ -function conversation(App $a, array $items, Pager $pager, $mode, $update, $preview = false, $order = 'commented', $uid = 0) +function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) { $ssl_state = (local_user() ? true : false); @@ -506,7 +505,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '') . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '') - . "'; var profile_page = " . $pager->getPage() . "; \r\n"; + . "'; \r\n"; } } elseif ($mode === 'profile') { $items = conversation_add_children($items, false, $order, $uid); @@ -525,7 +524,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ $live_update_div = '
' . "\r\n" . "\r\n"; + . "; var netargs = '?f='; \r\n"; } } } elseif ($mode === 'notes') { @@ -535,7 +534,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ if (!$update) { $live_update_div = '' . "\r\n" . "\r\n"; + . "; var netargs = '/?f='; \r\n"; } } elseif ($mode === 'display') { $items = conversation_add_children($items, false, $order, $uid); @@ -544,7 +543,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ if (!$update) { $live_update_div = '' . "\r\n" . ""; + . ""; } } elseif ($mode === 'community') { $items = conversation_add_children($items, true, $order, $uid); @@ -553,7 +552,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ if (!$update) { $live_update_div = '' . "\r\n" . "\r\n"; + ."/?f='; \r\n"; } } elseif ($mode === 'contacts') { $items = conversation_add_children($items, false, $order, $uid); @@ -562,7 +561,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ if (!$update) { $live_update_div = '' . "\r\n" . "\r\n"; + ."/?f='; \r\n"; } } elseif ($mode === 'search') { $live_update_div = '' . "\r\n"; diff --git a/mod/community.php b/mod/community.php index 7aa00240b..b95d13654 100644 --- a/mod/community.php +++ b/mod/community.php @@ -200,7 +200,7 @@ function community_content(App $a, $update = 0) $s = $r; } - $o .= conversation($a, $s, $pager, 'community', $update, false, 'commented', local_user()); + $o .= conversation($a, $s, 'community', $update, false, 'commented', local_user()); if (!$update) { $o .= $pager->renderMinimal(count($r)); diff --git a/mod/display.php b/mod/display.php index ea52a994b..dce8b25b9 100644 --- a/mod/display.php +++ b/mod/display.php @@ -331,7 +331,7 @@ function display_content(App $a, $update = false, $update_uid = 0) $o .= ""; } - $o .= conversation($a, [$item], new Pager(DI::args()->getQueryString()), 'display', $update_uid, false, 'commented', $item_uid); + $o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid); // Preparing the meta header $description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true)); diff --git a/mod/item.php b/mod/item.php index 636bd8c31..2e5a08203 100644 --- a/mod/item.php +++ b/mod/item.php @@ -675,7 +675,7 @@ function item_post(App $a) { $datarray["item_id"] = -1; $datarray["author-network"] = Protocol::DFRN; - $o = conversation($a, [array_merge($contact_record, $datarray)], new Pager(DI::args()->getQueryString()), 'search', false, true); + $o = conversation($a, [array_merge($contact_record, $datarray)], 'search', false, true); System::jsonExit(['preview' => $o]); } diff --git a/mod/network.php b/mod/network.php index 1f7afebf3..037a16ebf 100644 --- a/mod/network.php +++ b/mod/network.php @@ -291,7 +291,7 @@ function networkConversation(App $a, $items, Pager $pager, $mode, $update, $orde $items = []; } - $o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user()); + $o = conversation($a, $items, $mode, $update, false, $ordering, local_user()); if (!$update) { if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { diff --git a/mod/notes.php b/mod/notes.php index ccd30926c..34cf404ca 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -82,7 +82,7 @@ function notes_content(App $a, $update = false) $count = count($notes); - $o .= conversation($a, $notes, $pager, 'notes', $update); + $o .= conversation($a, $notes, 'notes', $update); } $o .= $pager->renderMinimal($count); diff --git a/src/Model/Contact.php b/src/Model/Contact.php index d3abc078c..789062403 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1815,13 +1815,13 @@ class Contact $items = Item::inArray($r); - $o = conversation($a, $items, $pager, 'contacts', $update, false, 'commented', local_user()); + $o = conversation($a, $items, 'contacts', $update, false, 'commented', local_user()); } else { $r = Item::selectForUser(local_user(), [], $condition, $params); $items = Item::inArray($r); - $o = conversation($a, $items, $pager, 'contact-posts', false); + $o = conversation($a, $items, 'contact-posts', false); } if (!$update) { diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 4cd14c021..8da831405 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -231,7 +231,7 @@ class Status extends BaseProfile $items = array_merge($items, $pinned); } - $o .= conversation($a, $items, $pager, 'profile', false, false, 'pinned_received', $a->profile['uid']); + $o .= conversation($a, $items, 'profile', false, false, 'pinned_received', $a->profile['uid']); $o .= $pager->renderMinimal(count($items)); diff --git a/src/Module/Search/Index.php b/src/Module/Search/Index.php index a68086ecc..3e174c790 100644 --- a/src/Module/Search/Index.php +++ b/src/Module/Search/Index.php @@ -200,7 +200,7 @@ class Index extends BaseSearch Logger::info('Start Conversation.', ['q' => $search]); - $o .= conversation(DI::app(), $r, $pager, 'search', false, false, 'commented', local_user()); + $o .= conversation(DI::app(), $r, 'search', false, false, 'commented', local_user()); $o .= $pager->renderMinimal(count($r)); diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index d23f766b5..79e53168b 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -95,8 +95,6 @@ class Profile extends BaseModule return ''; } - $pager = new Pager(DI::args()->getQueryString()); - // Set a time stamp for this page. We will make use of it when we // search for new items (update routine) $last_updated_array[$last_updated_key] = time(); @@ -116,7 +114,7 @@ class Profile extends BaseModule $items = DBA::toArray($items_stmt); - $o .= conversation($a, $items, $pager, 'profile', $profile_uid, false, 'received', $a->profile['uid']); + $o .= conversation($a, $items, 'profile', $profile_uid, false, 'received', $a->profile['uid']); header("Content-type: text/html"); echo "\r\n"; diff --git a/view/js/main.js b/view/js/main.js index 41bae7cf2..560d9c428 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -104,6 +104,20 @@ function decodeHtml(html) { return txt.value; } +/** + * Retrieves a single named query string parameter + * + * @param {string} name + * @returns {string} + * @see https://davidwalsh.name/query-string-javascript + */ +function getUrlParameter(name) { + name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); + var regex = new RegExp('[\\?&]' + name + '=([^]*)'); + var results = regex.exec(location.search); + return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); +}; + var src = null; var prev = null; var livetime = null; @@ -511,7 +525,11 @@ function updateConvItems(data) { var ident = $(this).attr('id'); // Add new top-level item. - if ($('#' + ident).length == 0 && profile_page == 1) { + if ($('#' + ident).length === 0 + && (!getUrlParameter('page') + || getUrlParameter('page') === '1' + ) + ) { $('#' + prev).after($(this)); // Replace already existing thread. @@ -573,7 +591,12 @@ function liveUpdate(src) { var orgHeight = $("section").height(); var udargs = ((netargs.length) ? '/' + netargs : ''); - var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&force=' + ((force_update) ? 1 : 0) + '&item=' + update_item; + + var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&force=' + ((force_update) ? 1 : 0) + '&item=' + update_item; + + if (getUrlParameter('page')) { + update_url += '&page=' + getUrlParameter('page'); + } $.get(update_url,function(data) { in_progress = false;