Endless scrolling on contact pages

This commit is contained in:
Michael 2020-09-29 20:47:19 +00:00
parent e55696c716
commit 887732b605

View file

@ -23,9 +23,11 @@ namespace Friendica\Model;
use Friendica\App\BaseURL;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -1283,6 +1285,11 @@ class Contact
if ($thread_mode) {
$condition = ["(`$contact_field` = ? OR (`causer-id` = ? AND `post-type` = ?)) AND `gravity` = ? AND " . $sql,
$cid, $cid, Item::PT_ANNOUNCEMENT, GRAVITY_PARENT, local_user()];
$last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
if (!empty($last_received)) {
$condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
}
} else {
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
@ -1302,6 +1309,13 @@ class Contact
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
if ($thread_mode) {
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
$r = Item::selectForUser(local_user(), ['uri', 'gravity', 'parent-uri'], $condition, $params);
$items = [];
while ($item = DBA::fetch($r)) {
@ -1315,7 +1329,7 @@ class Contact
}
DBA::close($r);
$o = conversation($a, $items, 'contacts', $update, false, 'commented', local_user());
$o .= conversation($a, $items, 'contacts', $update, false, 'commented', local_user());
} else {
$r = Item::selectForUser(local_user(), [], $condition, $params);
@ -1325,7 +1339,11 @@ class Contact
}
if (!$update) {
$o .= $pager->renderMinimal(count($items));
if ($thread_mode && DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
}
}
return $o;