mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
Remove pager parameter from conversation()
- Add getUrlParameter() Javascript function to determine current page
This commit is contained in:
parent
756de11cda
commit
0b0309ce8f
11 changed files with 42 additions and 22 deletions
|
@ -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() . "; </script>\r\n";
|
||||
. "'; </script>\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 = '<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') {
|
||||
|
@ -535,7 +534,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
|||
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);
|
||||
|
@ -544,7 +543,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
|||
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);
|
||||
|
@ -553,7 +552,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
|||
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);
|
||||
|
@ -562,7 +561,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
|||
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";
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -331,7 +331,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$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));
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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 "<!DOCTYPE html><html><body>\r\n";
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue