Remove pager parameter from conversation()
- Add getUrlParameter() Javascript function to determine current page
This commit is contained in:
parent
756de11cda
commit
0b0309ce8f
|
@ -460,7 +460,6 @@ function conv_get_blocklist()
|
||||||
* that are based on unique features of the calling module.
|
* that are based on unique features of the calling module.
|
||||||
* @param App $a
|
* @param App $a
|
||||||
* @param array $items
|
* @param array $items
|
||||||
* @param Pager $pager
|
|
||||||
* @param $mode
|
* @param $mode
|
||||||
* @param $update
|
* @param $update
|
||||||
* @param bool $preview
|
* @param bool $preview
|
||||||
|
@ -470,7 +469,7 @@ function conv_get_blocklist()
|
||||||
* @throws ImagickException
|
* @throws ImagickException
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @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);
|
$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['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
|
||||||
. (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
|
. (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
|
||||||
|
|
||||||
. "'; var profile_page = " . $pager->getPage() . "; </script>\r\n";
|
. "'; </script>\r\n";
|
||||||
}
|
}
|
||||||
} elseif ($mode === 'profile') {
|
} elseif ($mode === 'profile') {
|
||||||
$items = conversation_add_children($items, false, $order, $uid);
|
$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 = '<div id="live-profile"></div>' . "\r\n"
|
$live_update_div = '<div id="live-profile"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = " . $a->profile['uid']
|
. "<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') {
|
} elseif ($mode === 'notes') {
|
||||||
|
@ -535,7 +534,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = " . local_user()
|
. "<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') {
|
} elseif ($mode === 'display') {
|
||||||
$items = conversation_add_children($items, false, $order, $uid);
|
$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) {
|
if (!$update) {
|
||||||
$live_update_div = '<div id="live-display"></div>' . "\r\n"
|
$live_update_div = '<div id="live-display"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = " . Session::get('uid', 0) . ";"
|
. "<script> var profile_uid = " . Session::get('uid', 0) . ";"
|
||||||
. " var profile_page = 1; </script>";
|
. "</script>";
|
||||||
}
|
}
|
||||||
} elseif ($mode === 'community') {
|
} elseif ($mode === 'community') {
|
||||||
$items = conversation_add_children($items, true, $order, $uid);
|
$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) {
|
if (!$update) {
|
||||||
$live_update_div = '<div id="live-community"></div>' . "\r\n"
|
$live_update_div = '<div id="live-community"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
|
. "<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') {
|
} elseif ($mode === 'contacts') {
|
||||||
$items = conversation_add_children($items, false, $order, $uid);
|
$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) {
|
if (!$update) {
|
||||||
$live_update_div = '<div id="live-contacts"></div>' . "\r\n"
|
$live_update_div = '<div id="live-contacts"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
|
. "<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') {
|
} elseif ($mode === 'search') {
|
||||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||||
|
|
|
@ -200,7 +200,7 @@ function community_content(App $a, $update = 0)
|
||||||
$s = $r;
|
$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) {
|
if (!$update) {
|
||||||
$o .= $pager->renderMinimal(count($r));
|
$o .= $pager->renderMinimal(count($r));
|
||||||
|
|
|
@ -331,7 +331,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
||||||
$o .= "<script> var netargs = '?item_id=" . $item_id . "'; </script>";
|
$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
|
// Preparing the meta header
|
||||||
$description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
|
$description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
|
||||||
|
|
|
@ -675,7 +675,7 @@ function item_post(App $a) {
|
||||||
$datarray["item_id"] = -1;
|
$datarray["item_id"] = -1;
|
||||||
$datarray["author-network"] = Protocol::DFRN;
|
$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]);
|
System::jsonExit(['preview' => $o]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ function networkConversation(App $a, $items, Pager $pager, $mode, $update, $orde
|
||||||
$items = [];
|
$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 (!$update) {
|
||||||
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
|
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ function notes_content(App $a, $update = false)
|
||||||
|
|
||||||
$count = count($notes);
|
$count = count($notes);
|
||||||
|
|
||||||
$o .= conversation($a, $notes, $pager, 'notes', $update);
|
$o .= conversation($a, $notes, 'notes', $update);
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= $pager->renderMinimal($count);
|
$o .= $pager->renderMinimal($count);
|
||||||
|
|
|
@ -1815,13 +1815,13 @@ class Contact
|
||||||
|
|
||||||
$items = Item::inArray($r);
|
$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 {
|
} else {
|
||||||
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
||||||
|
|
||||||
$items = Item::inArray($r);
|
$items = Item::inArray($r);
|
||||||
|
|
||||||
$o = conversation($a, $items, $pager, 'contact-posts', false);
|
$o = conversation($a, $items, 'contact-posts', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
|
|
|
@ -231,7 +231,7 @@ class Status extends BaseProfile
|
||||||
$items = array_merge($items, $pinned);
|
$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));
|
$o .= $pager->renderMinimal(count($items));
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Index extends BaseSearch
|
||||||
|
|
||||||
Logger::info('Start Conversation.', ['q' => $search]);
|
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));
|
$o .= $pager->renderMinimal(count($r));
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,6 @@ class Profile extends BaseModule
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pager = new Pager(DI::args()->getQueryString());
|
|
||||||
|
|
||||||
// Set a time stamp for this page. We will make use of it when we
|
// Set a time stamp for this page. We will make use of it when we
|
||||||
// search for new items (update routine)
|
// search for new items (update routine)
|
||||||
$last_updated_array[$last_updated_key] = time();
|
$last_updated_array[$last_updated_key] = time();
|
||||||
|
@ -116,7 +114,7 @@ class Profile extends BaseModule
|
||||||
|
|
||||||
$items = DBA::toArray($items_stmt);
|
$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");
|
header("Content-type: text/html");
|
||||||
echo "<!DOCTYPE html><html><body>\r\n";
|
echo "<!DOCTYPE html><html><body>\r\n";
|
||||||
|
|
|
@ -104,6 +104,20 @@ function decodeHtml(html) {
|
||||||
return txt.value;
|
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 src = null;
|
||||||
var prev = null;
|
var prev = null;
|
||||||
var livetime = null;
|
var livetime = null;
|
||||||
|
@ -511,7 +525,11 @@ function updateConvItems(data) {
|
||||||
var ident = $(this).attr('id');
|
var ident = $(this).attr('id');
|
||||||
|
|
||||||
// Add new top-level item.
|
// Add new top-level item.
|
||||||
if ($('#' + ident).length == 0 && profile_page == 1) {
|
if ($('#' + ident).length === 0
|
||||||
|
&& (!getUrlParameter('page')
|
||||||
|
|| getUrlParameter('page') === '1'
|
||||||
|
)
|
||||||
|
) {
|
||||||
$('#' + prev).after($(this));
|
$('#' + prev).after($(this));
|
||||||
|
|
||||||
// Replace already existing thread.
|
// Replace already existing thread.
|
||||||
|
@ -573,7 +591,12 @@ function liveUpdate(src) {
|
||||||
var orgHeight = $("section").height();
|
var orgHeight = $("section").height();
|
||||||
|
|
||||||
var udargs = ((netargs.length) ? '/' + netargs : '');
|
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) {
|
$.get(update_url,function(data) {
|
||||||
in_progress = false;
|
in_progress = false;
|
||||||
|
|
Loading…
Reference in a new issue