1
0
Fork 0

Merge pull request #10160 from annando/issue-10156

Issue 10156: Fix endless scroll with filed posts
This commit is contained in:
Hypolite Petovan 2021-04-20 23:42:24 -04:00 committed by GitHub
commit 5a8f202158
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,16 +47,23 @@ class Filed extends BaseSearch
DI::config()->get('system', 'itemspage_network')); DI::config()->get('system', 'itemspage_network'));
} }
$last_uriid = isset($_GET['last_uriid']) ? intval($_GET['last_uriid']) : 0;
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network); $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
$term_condition = ['type' => Category::FILE, 'uid' => local_user()]; $term_condition = ['type' => Category::FILE, 'uid' => local_user()];
if ($file) { if ($file) {
$term_condition['name'] = $file; $term_condition['name'] = $file;
} }
if (!empty($last_uriid)) {
$term_condition = DBA::mergeConditions($term_condition, ["`uri-id` < ?", $last_uriid]);
}
$term_params = ['order' => ['uri-id' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; $term_params = ['order' => ['uri-id' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$result = DBA::select('category-view', ['uri-id'], $term_condition, $term_params); $result = DBA::select('category-view', ['uri-id'], $term_condition, $term_params);
$total = DBA::count('category-view', $term_condition); $count = DBA::count('category-view', $term_condition);
$posts = []; $posts = [];
while ($term = DBA::fetch($result)) { while ($term = DBA::fetch($result)) {
@ -77,7 +84,7 @@ class Filed extends BaseSearch
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader(); $o .= HTML::scrollLoader();
} else { } else {
$o .= $pager->renderFull($total); $o .= $pager->renderMinimal($count);
} }
return $o; return $o;