Skip to content

Commit

Permalink
cleanup: DataLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteimen committed Jan 27, 2023
1 parent 6b71aca commit 82097c0
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ private CompletableFuture<Payment> loadAsync(Record item, BalanceRefresher br) {
var loadWalletInfo = loadWalletInfoAsync(item);
var loadExchangeRate = new CompletableFuture<Void>();
if (model.getActor() == Actor.Receiver) {
loadExchangeRate = exchangeRateLoader.loadAsync(p).thenAccept(t -> {
model.onTransactionChanged(p);
});
loadExchangeRate = exchangeRateLoader.loadAsync(p).thenAccept(t -> model.onTransactionChanged(p));
} else {
loadExchangeRate.complete(null);
}
Expand All @@ -85,9 +83,7 @@ private CompletableFuture<Payment> loadAsync(Record item, BalanceRefresher br) {
CompletableFuture.allOf(loadBalancesAndHistory).join();
CompletableFuture.allOf(loadWalletInfo, finalLoadExchangeRate).join();
// Validation can start after loadExchangeRate completed.
validateAsync(item).thenAccept((result) -> {
future.complete(p);
});
validateAsync(item).thenAccept((result) -> future.complete(p));
});
return future;
}
Expand All @@ -104,9 +100,7 @@ private CompletableFuture<Void> loadWalletInfoAsync(Record item) {

private CompletableFuture<Void> validateAsync(Record item) {
var av = new AsyncValidator(validator);
return av.validate(item.payment).thenAccept(result -> {
model.setValidationResults(item.payment, result.right);
});
return av.validate(item.payment).thenAccept(result -> model.setValidationResults(item.payment, result.right));
}

public void onAccountOrWalletsChanged(Payment t) {
Expand Down

0 comments on commit 82097c0

Please sign in to comment.