indicate when initially loading a wallets transactions in status bar

This commit is contained in:
Craig Raw 2021-03-08 10:45:29 +02:00
parent 07ed9c857b
commit 13d701b0a7
5 changed files with 53 additions and 4 deletions

View file

@ -1347,6 +1347,28 @@ public class AppController implements Initializable {
} }
} }
@Subscribe
public void walletHistoryStarted(WalletHistoryStartedEvent event) {
if(AppServices.isConnected() && getOpenWallets().containsKey(event.getWallet())) {
statusUpdated(new StatusEvent("Loading transactions...", 120));
if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) {
statusBar.setProgress(-1);
}
}
}
@Subscribe
public void walletHistoryFinished(WalletHistoryFinishedEvent event) {
if(getOpenWallets().containsKey(event.getWallet())) {
if(statusBar.getText().equals("Loading transactions...")) {
statusBar.setText("");
}
if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) {
statusBar.setProgress(0);
}
}
}
@Subscribe @Subscribe
public void bwtBootStatus(BwtBootStatusEvent event) { public void bwtBootStatus(BwtBootStatusEvent event) {
serverToggle.setDisable(true); serverToggle.setDisable(true);

View file

@ -0,0 +1,13 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.wallet.Wallet;
public class WalletHistoryFinishedEvent extends WalletHistoryStatusEvent {
public WalletHistoryFinishedEvent(Wallet wallet) {
super(wallet, false);
}
public WalletHistoryFinishedEvent(Wallet wallet, String errorMessage) {
super(wallet, errorMessage);
}
}

View file

@ -0,0 +1,9 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.wallet.Wallet;
public class WalletHistoryStartedEvent extends WalletHistoryStatusEvent {
public WalletHistoryStartedEvent(Wallet wallet) {
super(wallet, true);
}
}

View file

@ -24,7 +24,7 @@ public class WalletHistoryStatusEvent {
public WalletHistoryStatusEvent(Wallet wallet, String errorMessage) { public WalletHistoryStatusEvent(Wallet wallet, String errorMessage) {
this.wallet = wallet; this.wallet = wallet;
this.loading = true; this.loading = false;
this.statusMessage = null; this.statusMessage = null;
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }

View file

@ -100,14 +100,19 @@ public class WalletForm {
log.debug(node == null ? wallet.getName() + " refreshing full wallet history" : wallet.getName() + " requesting node wallet history for " + node.getDerivationPath()); log.debug(node == null ? wallet.getName() + " refreshing full wallet history" : wallet.getName() + " requesting node wallet history for " + node.getDerivationPath());
ElectrumServer.TransactionHistoryService historyService = new ElectrumServer.TransactionHistoryService(wallet, getWalletTransactionNodes(node)); ElectrumServer.TransactionHistoryService historyService = new ElectrumServer.TransactionHistoryService(wallet, getWalletTransactionNodes(node));
historyService.setOnSucceeded(workerStateEvent -> { historyService.setOnSucceeded(workerStateEvent -> {
EventManager.get().post(new WalletHistoryStatusEvent(wallet, false)); EventManager.get().post(new WalletHistoryFinishedEvent(wallet));
updateWallet(blockHeight, pastWallet, previousWallet); updateWallet(blockHeight, pastWallet, previousWallet);
}); });
historyService.setOnFailed(workerStateEvent -> { historyService.setOnFailed(workerStateEvent -> {
log.error("Error retrieving wallet history", workerStateEvent.getSource().getException()); log.error("Error retrieving wallet history", workerStateEvent.getSource().getException());
EventManager.get().post(new WalletHistoryStatusEvent(wallet, workerStateEvent.getSource().getException().getMessage())); EventManager.get().post(new WalletHistoryFinishedEvent(wallet, workerStateEvent.getSource().getException().getMessage()));
}); });
if(node == null && wallet.getTransactions().isEmpty()) {
EventManager.get().post(new WalletHistoryStartedEvent(wallet));
} else {
EventManager.get().post(new WalletHistoryStatusEvent(wallet, true)); EventManager.get().post(new WalletHistoryStatusEvent(wallet, true));
}
historyService.start(); historyService.start();
} }
} }