show progress indicator when retrieving paynym

This commit is contained in:
Craig Raw 2021-12-09 12:04:53 +02:00
parent 238aae5ea9
commit cf2616ec2b
2 changed files with 11 additions and 0 deletions

View file

@ -47,6 +47,9 @@ public class PayNymController extends SorobanController {
@FXML @FXML
private Button payNymRetrieve; private Button payNymRetrieve;
@FXML
private ProgressIndicator retrievePayNymProgress;
@FXML @FXML
private PaymentCodeTextField paymentCode; private PaymentCodeTextField paymentCode;
@ -76,6 +79,10 @@ public class PayNymController extends SorobanController {
payNymRetrieve.managedProperty().bind(payNymRetrieve.visibleProperty()); payNymRetrieve.managedProperty().bind(payNymRetrieve.visibleProperty());
payNymRetrieve.visibleProperty().bind(payNymName.visibleProperty().not()); payNymRetrieve.visibleProperty().bind(payNymName.visibleProperty().not());
retrievePayNymProgress.managedProperty().bind(retrievePayNymProgress.visibleProperty());
retrievePayNymProgress.maxHeightProperty().bind(payNymName.heightProperty());
retrievePayNymProgress.setVisible(false);
Soroban soroban = AppServices.getSorobanServices().getSoroban(walletId); Soroban soroban = AppServices.getSorobanServices().getSoroban(walletId);
if(soroban.getPaymentCode() != null) { if(soroban.getPaymentCode() != null) {
paymentCode.setPaymentCode(soroban.getPaymentCode()); paymentCode.setPaymentCode(soroban.getPaymentCode());
@ -145,8 +152,10 @@ public class PayNymController extends SorobanController {
if(soroban.getPaymentCode() == null) { if(soroban.getPaymentCode() == null) {
throw new IllegalStateException("Payment code has not been set"); throw new IllegalStateException("Payment code has not been set");
} }
retrievePayNymProgress.setVisible(true);
soroban.getPayNym(soroban.getPaymentCode().toString()).subscribe(payNym -> { soroban.getPayNym(soroban.getPaymentCode().toString()).subscribe(payNym -> {
retrievePayNymProgress.setVisible(false);
walletPayNym = payNym; walletPayNym = payNym;
payNymName.setText(payNym.nymName()); payNymName.setText(payNym.nymName());
paymentCode.setPaymentCode(payNym.paymentCode()); paymentCode.setPaymentCode(payNym.paymentCode());
@ -157,6 +166,7 @@ public class PayNymController extends SorobanController {
followersList.setPlaceholder(new Label("No followers")); followersList.setPlaceholder(new Label("No followers"));
followersList.setItems(FXCollections.observableList(payNym.followers())); followersList.setItems(FXCollections.observableList(payNym.followers()));
}, error -> { }, error -> {
retrievePayNymProgress.setVisible(false);
if(error.getMessage().endsWith("404")) { if(error.getMessage().endsWith("404")) {
payNymName.setVisible(false); payNymName.setVisible(false);
} else { } else {

View file

@ -41,6 +41,7 @@
<Tooltip text="Retrieves and claims the PayNym for this wallet" /> <Tooltip text="Retrieves and claims the PayNym for this wallet" />
</tooltip> </tooltip>
</Button> </Button>
<ProgressIndicator fx:id="retrievePayNymProgress" />
</HBox> </HBox>
<HBox styleClass="field-box"> <HBox styleClass="field-box">
<Label text="Payment code:" styleClass="field-label" /> <Label text="Payment code:" styleClass="field-label" />