Issue 9288: Endless scrolling on the community page

This commit is contained in:
Michael 2020-09-27 05:25:32 +00:00
parent 26d23a3ee3
commit 55aa9c1cca

View File

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Content\BoundariesPager;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Text\HTML;
use Friendica\Content\Widget\TrendingTags;
use Friendica\Core\ACL;
use Friendica\Core\Renderer;
@ -35,6 +36,7 @@ use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat;
class Community extends BaseModule
{
@ -47,6 +49,9 @@ class Community extends BaseModule
public static function content(array $parameters = [])
{
// Rawmode is used for fetching new content at the end of the page
$rawmode = (isset($_GET['mode']) AND ($_GET['mode'] == 'raw'));
self::parseRequest($parameters);
$tabs = [];
@ -73,8 +78,17 @@ class Community extends BaseModule
];
}
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
if (!$rawmode) {
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
$o = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
$o .= Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
}
Nav::setSelected('community');
@ -111,8 +125,13 @@ class Community extends BaseModule
self::$itemsPerPage
);
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
}
if (!$rawmode) {
DI::page()['aside'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/community_accounts.tpl'), [
'$title' => DI::l10n()->t('Accounts'),
'$content' => self::$content,
@ -123,8 +142,9 @@ class Community extends BaseModule
'$news' => DI::l10n()->t('News'),
'$community' => DI::l10n()->t('Forums'),
]);
}
if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
if (!$rawmode && local_user() && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content . ($parameters['accounttype'] ? '/' . $parameters['accounttype'] : '');
$query_parameters = [];
@ -134,6 +154,9 @@ class Community extends BaseModule
if (!empty($_GET['max_id'])) {
$query_parameters['max_id'] = $_GET['max_id'];
}
if (!empty($_GET['last_commented'])) {
$query_parameters['max_id'] = DateTimeFormat::utc($_GET['last_commented']);
}
$path_all = $path . (!empty($query_parameters) ? '?' . http_build_query($query_parameters) : '');
$path_no_sharer = $path . '?' . http_build_query(array_merge($query_parameters, ['no_sharer' => true]));
@ -147,7 +170,7 @@ class Community extends BaseModule
]);
}
if (Feature::isEnabled(local_user(), 'trending_tags')) {
if (!$rawmode && Feature::isEnabled(local_user(), 'trending_tags')) {
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
}
@ -245,6 +268,7 @@ class Community extends BaseModule
self::$since_id = $_GET['since_id'] ?? null;
self::$max_id = $_GET['max_id'] ?? null;
self::$max_id = $_GET['last_commented'] ?? self::$max_id;
}
/**