Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Oct 17, 2024
1 parent 0a3c915 commit c1a9e8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CompletableFuture<ConsumerService.State> handleRender(
) {
final ContextElementRender context = ctx.context();
final ElementPaginationRich<?> pagination = (ElementPaginationRich<?>) context.element();
if (pagination.initialized() && !pagination.pageWasChanged()) {
if (pagination.initialized() && !pagination.pageWasChanged() && !context.forced()) {
pagination.visible(true);
return this.renderChild(context, pagination);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import net.infumia.frame.service.ConsumerService;
import net.infumia.frame.slot.LayoutSlot;
import net.infumia.frame.state.State;
import net.infumia.frame.state.StateRich;
import net.infumia.frame.state.pagination.ElementConfigurer;
import net.infumia.frame.state.pagination.StatePagination;
import net.infumia.frame.util.Preconditions;
Expand Down Expand Up @@ -433,29 +432,21 @@ private CompletableFuture<List<T>> loadSourceForTheCurrentPage(
}

this.loading = true;
return ((StateRich<ElementPagination>) this.associated).manualUpdateWait(
context
).thenCompose(__ -> {
if (this.sourceFactory == null) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
return this.sourceFactory.apply(context).thenCompose(result -> {
this.currentSource = result;
this.pageCount = this.calculatePagesCount(result);
this.loading = false;
return ((StateRich<ElementPagination>) this.associated).manualUpdateWait(
context
).thenApply(value ->
!isLazy
? result
: ElementPaginationImpl.splitSourceForPage(
this.currentPageIndex,
this.pageSize(),
this.pageCount,
result
)
);
});
if (this.sourceFactory == null) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
return this.sourceFactory.apply(context).thenApply(result -> {
this.currentSource = result;
this.pageCount = this.calculatePagesCount(result);
this.loading = false;
return !isLazy
? result
: ElementPaginationImpl.splitSourceForPage(
this.currentPageIndex,
this.pageSize(),
this.pageCount,
result
);
});
}

Expand Down Expand Up @@ -502,7 +493,7 @@ private static <T> List<T> splitSourceForPage(
if (src.size() <= pageSize) {
return new ArrayList<>(src);
}
if (index < 0 || (pagesCount > 0 && index > pagesCount)) {
if (index < 0 || (pagesCount > 0 && index >= pagesCount)) {
throw new IndexOutOfBoundsException(
String.format(
"Page index must be between the range of 0 and %d. Given: %d",
Expand Down

0 comments on commit c1a9e8b

Please sign in to comment.