Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions assets/controllers/infinite_scroll_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ export default class extends Controller {
try {
this.loadingValue = true;

const paginationElem = this.paginationTarget.getElementsByClassName('pagination__item--current-page')[0].nextElementSibling;
if (paginationElem.classList.contains('pagination__item--disabled')) {
throw new Error('No more pages');
const cursorPaginationElement = this.paginationTarget.getElementsByClassName('cursor-pagination');
let paginationElem = null;
if (cursorPaginationElement.length) {
console.log(cursorPaginationElement[0]);
const button = cursorPaginationElement[0].getElementsByTagName('a');
if (!button.length) {
throw new Error('No more pages');
}
paginationElem = button[0];
} else {
paginationElem = this.paginationTarget.getElementsByClassName('pagination__item--current-page')[0].nextElementSibling;
if (paginationElem.classList.contains('pagination__item--disabled')) {
throw new Error('No more pages');
}
}

if (window.infiniteScrollUrls.includes(paginationElem.href)) {
Expand Down
11 changes: 11 additions & 0 deletions assets/styles/layout/_section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@
color: var(--kbin-alert-danger-text-color);
}
}

.cursor-pagination .section {
text-align: center;
padding: .25rem;

a {
display: inline-block;
width: 25%;
min-width: 250px;
}
}
14 changes: 14 additions & 0 deletions config/mbin_routes/combined_api.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
api_combined_cursor:
controller: App\Controller\Api\Combined\CombinedRetrieveApi::cursorCollection
path: /api/combined/2.0
methods: [ GET ]
format: json

api_combined_user_cursor:
controller: App\Controller\Api\Combined\CombinedRetrieveApi::cursorUserCollection
path: /api/combined/2.0/{contentType}
requirements:
contentType: subscribed|moderated|favourited
methods: [ PUT ]
format: json

api_combined:
controller: App\Controller\Api\Combined\CombinedRetrieveApi::collection
path: /api/combined
Expand Down
10 changes: 10 additions & 0 deletions src/Controller/Api/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use App\Factory\PostFactory;
use App\Factory\UserFactory;
use App\Form\Constraint\ImageConstraint;
use App\Pagination\Cursor\CursorPaginationInterface;
use App\Repository\BookmarkListRepository;
use App\Repository\BookmarkRepository;
use App\Repository\Criteria;
Expand All @@ -55,6 +56,7 @@
use App\Repository\ReputationRepository;
use App\Repository\TagLinkRepository;
use App\Repository\UserRepository;
use App\Schema\CursorPaginationSchema;
use App\Schema\PaginationSchema;
use App\Service\BookmarkManager;
use App\Service\InstanceManager;
Expand Down Expand Up @@ -233,6 +235,14 @@ public function serializePaginated(array $serializedItems, PagerfantaInterface $
];
}

public function serializeCursorPaginated(array $serializedItems, CursorPaginationInterface $pagerfanta): array
{
return [
'items' => $serializedItems,
'pagination' => new CursorPaginationSchema($pagerfanta),
];
}

public function serializeContentInterface(ContentInterface $content, bool $forceVisible = false): mixed
{
$toReturn = null;
Expand Down
Loading
Loading