Prevent loading empty next page in P/E infinite scroll [SCI-7160] (#4410)

This commit is contained in:
artoscinote 2022-09-06 11:57:34 +02:00 committed by GitHub
parent 9126b7fca4
commit 21f91089e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -485,6 +485,11 @@ var ProjectsIndex = (function() {
if (viewContainer.find('.no-results-container').length) { if (viewContainer.find('.no-results-container').length) {
viewContainer.addClass('no-results'); viewContainer.addClass('no-results');
} }
if (!data.next_page) {
$(cardsWrapper).addClass('last-page');
}
selectedProjects.length = 0; selectedProjects.length = 0;
selectedProjectFolders.length = 0; selectedProjectFolders.length = 0;
updateProjectsToolbar(); updateProjectsToolbar();
@ -497,6 +502,7 @@ var ProjectsIndex = (function() {
placeholderTemplate: '#projectPlaceholder', placeholderTemplate: '#projectPlaceholder',
endOfListTemplate: '#projectEndOfList', endOfListTemplate: '#projectEndOfList',
pageSize: pageSize, pageSize: pageSize,
lastPage: !!data.next_page,
customResponse: (response) => { customResponse: (response) => {
$(response.cards_html).appendTo(cardsWrapper); $(response.cards_html).appendTo(cardsWrapper);
}, },

View file

@ -46,6 +46,11 @@ var InfiniteScroll = (function() {
var $container = $(object); var $container = $(object);
$container.data('next-page', 2); $container.data('next-page', 2);
$container.data('config', config); $container.data('config', config);
if (config.lastPage) {
$container.addClass('last-page');
}
if (config.loadFirstPage) { if (config.loadFirstPage) {
loadData($container, 1); loadData($container, 1);
} }