stop progress bar when loading wallet is closed

This commit is contained in:
Craig Raw 2021-03-10 13:49:21 +02:00
parent ff962aa5f0
commit d67dd515c4

View file

@ -120,6 +120,8 @@ public class AppController implements Initializable {
private Timeline statusTimeline; private Timeline statusTimeline;
private final List<Wallet> loadingWallets = new ArrayList<>();
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
EventManager.get().register(this); EventManager.get().register(this);
@ -1370,12 +1372,25 @@ public class AppController implements Initializable {
} }
} }
@Subscribe
public void walletTabsClosed(WalletTabsClosedEvent event) {
if(event.getClosedWalletTabData().stream().map(WalletTabData::getWallet).anyMatch(loadingWallets::remove) && loadingWallets.isEmpty()) {
if(statusBar.getText().equals("Loading transactions...")) {
statusBar.setText("");
}
if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) {
statusBar.setProgress(0);
}
}
}
@Subscribe @Subscribe
public void walletHistoryStarted(WalletHistoryStartedEvent event) { public void walletHistoryStarted(WalletHistoryStartedEvent event) {
if(AppServices.isConnected() && getOpenWallets().containsKey(event.getWallet())) { if(AppServices.isConnected() && getOpenWallets().containsKey(event.getWallet())) {
statusUpdated(new StatusEvent("Loading transactions...", 120)); statusUpdated(new StatusEvent("Loading transactions...", 120));
if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) { if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) {
statusBar.setProgress(-1); statusBar.setProgress(-1);
loadingWallets.add(event.getWallet());
} }
} }
} }
@ -1389,6 +1404,7 @@ public class AppController implements Initializable {
if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) { if(statusTimeline == null || statusTimeline.getStatus() != Animation.Status.RUNNING) {
statusBar.setProgress(0); statusBar.setProgress(0);
} }
loadingWallets.remove(event.getWallet());
} }
} }