Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ public interface Pagination extends ComponentComposition, StateValue {
@ApiStatus.Experimental
boolean isLoading();

/**
* Forces the pagination to update everything internally ignoring everything, including
* {@link #isLazy() lazy} data source to be computed again.
*
* <p><b><i> This API is experimental and is not subject to the general compatibility guarantees
* such API may be changed or may be removed completely in any further release. </i></b>
*/
@ApiStatus.Experimental
void forceUpdate();

/**
* Gets all elements in a given page index based of the specified source.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class PaginationImpl extends AbstractStateValue implements Pagination, In
private boolean pageWasChanged;
private boolean initialized;
private int pagesCount;
private boolean forceUpdated;

// Number of elements that each page can have. -1 means uninitialized.
private int pageSize = -1;
Expand Down Expand Up @@ -107,7 +108,7 @@ private CompletableFuture<List<?>> loadSourceForTheCurrentPage() {
*/
final boolean reuseLazy = isLazy() && initialized;

if ((isStatic() || reuseLazy) && !isComputed()) {
if ((isStatic() || reuseLazy) && !isComputed() && !forceUpdated) {
// For unknown reasons already initialized but source is null, external modification?
if (initialized && currSource == null)
throw new IllegalStateException("User provided pagination source cannot be null");
Expand Down Expand Up @@ -359,7 +360,7 @@ public void updated(@NotNull IFSlotRenderContext context) {
final IFRenderContext renderContext = context.getParent();

// If page was changed all components will be removed, so don't trigger update on them
if (pageWasChanged) {
if (forceUpdated || pageWasChanged) {
getInternalComponents().forEach(child -> child.clear(renderContext));
components = new ArrayList<>();
getInternalComponents().clear();
Expand Down Expand Up @@ -570,7 +571,7 @@ public void clicked(@NotNull Component component, @NotNull IFSlotClickContext co
if (child.getInteractionHandler() == null || !child.isVisible()) {
continue;
}
;

if (child.isContainedWithin(context.getClickedSlot())) {
child.getInteractionHandler().clicked(component, context);
break;
Expand All @@ -593,6 +594,13 @@ public void update() {
((IFContext) getRoot()).updateComponent(this);
}

@Override
public void forceUpdate() {
forceUpdated = true;
update();
forceUpdated = false;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public final void navigateTo(
@SuppressWarnings({"rawtypes", "unchecked"})
@ApiStatus.Internal
public final void back(@NotNull Viewer viewer) {
final IFRenderContext active = viewer.getActiveContext();
final IFRenderContext target = viewer.getPreviousContext();
viewer.unsetPreviousContext();
viewer.setTransitioning(true);
Expand All @@ -181,6 +182,7 @@ public final void back(@NotNull Viewer viewer) {
root.renderContext(target);
}
viewer.setTransitioning(false);
((PlatformView) target.getRoot()).onResume(active, target);
}

private void setupNavigateTo(@NotNull Viewer viewer, @NotNull IFRenderContext origin) {
Expand Down