Skip to content

Commit

Permalink
simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
portlek committed Oct 17, 2024
1 parent 1cc585b commit aecd392
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ public CompletableFuture<ConsumerService.State> handleUpdate(
final List<Element> elements = pagination.elements();
final CompletableFuture<?>[] futures = new CompletableFuture<?>[elements.size()];
for (int i = 0; i < futures.length; i++) {
futures[i] = ((ElementRich) elements.get(i)).pipelines()
.executeUpdate(context, context.forced());
final ElementRich element = (ElementRich) elements.get(i);
if (context.forced()) {
futures[i] = element.forceUpdate();
} else {
futures[i] = element.update();
}
}
return CompletableFuture.allOf(futures).thenApply(__ -> ConsumerService.State.CONTINUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void switchTo(final int pageIndex) {
this.onPageSwitch.accept(host, this);
}
CompletableFutureExtensions.logError(
this.pipelines.executeUpdate(host, false),
this.update(),
this.parent().frame().logger(),
"An error occurred while updating the pagination '%s'.",
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.concurrent.CompletableFuture;
import net.infumia.frame.context.element.ContextElementClick;
import net.infumia.frame.element.Element;
import net.infumia.frame.element.ElementRich;
import net.infumia.frame.pipeline.PipelineServiceConsumer;
import net.infumia.frame.pipeline.context.PipelineContextElement;
import org.jetbrains.annotations.NotNull;
Expand All @@ -28,7 +27,7 @@ public CompletableFuture<State> handle(@NotNull final PipelineContextElement.Cli
final ContextElementClick context = ctx.context();
final Element element = context.element();
if (element.updateOnClick()) {
return ((ElementRich) element).pipelines().executeUpdate(context, false);
return element.update();
}
return CompletableFuture.completedFuture(State.CONTINUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static void updateOnStateAccess(
for (final net.infumia.frame.state.State<?> state : states) {
state.watchAccess(context, update ->
CompletableFutureExtensions.logError(
element.pipelines().executeUpdate(context, false),
element.update(),
context.frame().logger(),
"An error occurred while updating element '%s' due to state '%s' access!",
element.key(),
Expand All @@ -78,7 +78,7 @@ private static void updateOnStateChange(
for (final net.infumia.frame.state.State<?> state : states) {
state.watchUpdate(context, update ->
CompletableFutureExtensions.logError(
element.pipelines().executeUpdate(context, false),
element.update(),
context.frame().logger(),
"An error occurred while updating element '%s' due to state '%s' change!",
element.key(),
Expand Down

0 comments on commit aecd392

Please sign in to comment.