mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
ui fixes to mix start and stop
This commit is contained in:
parent
f74287697c
commit
0b55dd8a1e
2 changed files with 25 additions and 6 deletions
|
@ -79,7 +79,14 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
};
|
||||
|
||||
private final ChangeListener<Boolean> mixingStartingListener = (observable, oldValue, newValue) -> {
|
||||
startMix.setDisable(newValue);
|
||||
startMix.setDisable(newValue || !AppServices.onlineProperty().get());
|
||||
Platform.runLater(() -> startMix.setText(newValue && AppServices.onlineProperty().get() ? "Starting Mixing..." : "Start Mixing"));
|
||||
mixTo.setDisable(newValue);
|
||||
};
|
||||
|
||||
private final ChangeListener<Boolean> mixingStoppingListener = (observable, oldValue, newValue) -> {
|
||||
startMix.setDisable(newValue || !AppServices.onlineProperty().get());
|
||||
Platform.runLater(() -> startMix.setText(newValue ? "Stopping Mixing..." : "Start Mixing"));
|
||||
mixTo.setDisable(newValue);
|
||||
};
|
||||
|
||||
|
@ -101,7 +108,6 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
startMix.visibleProperty().bind(stopMix.visibleProperty().not());
|
||||
stopMix.visibleProperty().addListener((observable, oldValue, newValue) -> {
|
||||
stopMix.setDisable(!newValue);
|
||||
startMix.setDisable(newValue || !AppServices.onlineProperty().get());
|
||||
});
|
||||
mixTo.managedProperty().bind(mixTo.visibleProperty());
|
||||
mixTo.setVisible(getWalletForm().getWallet().getStandardAccountType() == StandardAccount.WHIRLPOOL_POSTMIX);
|
||||
|
@ -111,6 +117,7 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
if(whirlpool != null) {
|
||||
stopMix.visibleProperty().bind(whirlpool.mixingProperty());
|
||||
whirlpool.startingProperty().addListener(new WeakChangeListener<>(mixingStartingListener));
|
||||
whirlpool.stoppingProperty().addListener(new WeakChangeListener<>(mixingStoppingListener));
|
||||
updateMixToButton();
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +329,7 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
|
||||
public void stopMixing(ActionEvent event) {
|
||||
stopMix.setDisable(true);
|
||||
startMix.setDisable(false);
|
||||
startMix.setDisable(!AppServices.onlineProperty().get());
|
||||
|
||||
getWalletForm().getWallet().getMasterMixConfig().setMixOnStartup(Boolean.FALSE);
|
||||
EventManager.get().post(new WalletMasterMixConfigChangedEvent(getWalletForm().getWallet()));
|
||||
|
|
|
@ -76,6 +76,7 @@ public class Whirlpool {
|
|||
private String mixToWalletId;
|
||||
|
||||
private final BooleanProperty startingProperty = new SimpleBooleanProperty(false);
|
||||
private final BooleanProperty stoppingProperty = new SimpleBooleanProperty(false);
|
||||
private final BooleanProperty mixingProperty = new SimpleBooleanProperty(false);
|
||||
|
||||
public Whirlpool(Network network, HostAndPort torProxy) {
|
||||
|
@ -408,6 +409,14 @@ public class Whirlpool {
|
|||
return startingProperty;
|
||||
}
|
||||
|
||||
public boolean isStopping() {
|
||||
return stoppingProperty.get();
|
||||
}
|
||||
|
||||
public BooleanProperty stoppingProperty() {
|
||||
return stoppingProperty;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMixSuccess(MixSuccessEvent e) {
|
||||
WalletUtxo walletUtxo = getUtxo(e.getWhirlpoolUtxo());
|
||||
|
@ -547,8 +556,8 @@ public class Whirlpool {
|
|||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
||||
if(AppServices.onlineProperty().get()) {
|
||||
whirlpoolWallet.start();
|
||||
whirlpool.startingProperty.set(false);
|
||||
}
|
||||
whirlpool.startingProperty.set(false);
|
||||
|
||||
return whirlpoolWallet;
|
||||
}
|
||||
|
@ -569,8 +578,9 @@ public class Whirlpool {
|
|||
protected Boolean call() throws Exception {
|
||||
updateProgress(-1, 1);
|
||||
updateMessage("Disconnecting from Whirlpool...");
|
||||
|
||||
whirlpool.stoppingProperty.set(true);
|
||||
whirlpool.shutdown();
|
||||
whirlpool.stoppingProperty.set(false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -590,15 +600,17 @@ public class Whirlpool {
|
|||
protected Boolean call() throws Exception {
|
||||
updateProgress(-1, 1);
|
||||
updateMessage("Disconnecting from Whirlpool...");
|
||||
whirlpool.stoppingProperty.set(true);
|
||||
whirlpool.shutdown();
|
||||
whirlpool.stoppingProperty.set(false);
|
||||
|
||||
updateMessage("Starting Whirlpool...");
|
||||
whirlpool.startingProperty.set(true);
|
||||
WhirlpoolWallet whirlpoolWallet = whirlpool.getWhirlpoolWallet();
|
||||
if(AppServices.onlineProperty().get()) {
|
||||
whirlpoolWallet.start();
|
||||
whirlpool.startingProperty.set(false);
|
||||
}
|
||||
whirlpool.startingProperty.set(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue