* 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
* @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);
. (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
. (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
- . "'; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+ . "'; </script>\r\n";
}
} elseif ($mode === 'profile') {
$items = conversation_add_children($items, false, $order, $uid);
$live_update_div = '<div id="live-profile"></div>' . "\r\n"
. "<script> var profile_uid = " . $a->profile['uid']
- . "; var netargs = '?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+ . "; var netargs = '?f='; </script>\r\n";
}
}
} elseif ($mode === 'notes') {
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
. "<script> var profile_uid = " . local_user()
- . "; var netargs = '/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+ . "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
$items = conversation_add_children($items, false, $order, $uid);
if (!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n"
. "<script> var profile_uid = " . Session::get('uid', 0) . ";"
- . " var profile_page = 1; </script>";
+ . "</script>";
}
} elseif ($mode === 'community') {
$items = conversation_add_children($items, true, $order, $uid);
if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
- ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+ ."/?f='; </script>\r\n";
}
} elseif ($mode === 'contacts') {
$items = conversation_add_children($items, false, $order, $uid);
if (!$update) {
$live_update_div = '<div id="live-contacts"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
- ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+ ."/?f='; </script>\r\n";
}
} elseif ($mode === 'search') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
$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));
$o .= "<script> var netargs = '?item_id=" . $item_id . "'; </script>";
}
- $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));
$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]);
}
$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')) {
$count = count($notes);
- $o .= conversation($a, $notes, $pager, 'notes', $update);
+ $o .= conversation($a, $notes, 'notes', $update);
}
$o .= $pager->renderMinimal($count);
$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) {
$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));
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));
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();
$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 "<!DOCTYPE html><html><body>\r\n";
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;
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.
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;