From e23c1b387292ceff825173461861ebed492065c7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 4 Sep 2023 09:47:41 +0200 Subject: [PATCH] force selection of a new configured server if currently configured server is deleted --- .../sparrow/preferences/ServerAliasDialog.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerAliasDialog.java b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerAliasDialog.java index 11766ba8..c6617eae 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/ServerAliasDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/ServerAliasDialog.java @@ -26,6 +26,7 @@ import java.util.stream.Collectors; public class ServerAliasDialog extends Dialog { private final ServerType serverType; private final TableView serverTable; + private final Button closeButton; public ServerAliasDialog(ServerType serverType) { this.serverType = serverType; @@ -76,6 +77,7 @@ public class ServerAliasDialog extends Dialog { Button selectButton = (Button)dialogPane.lookupButton(selectButtonType); Button deleteButton = (Button)dialogPane.lookupButton(deleteButtonType); + closeButton = (Button)dialogPane.lookupButton(ButtonType.CLOSE); selectButton.setDefaultButton(true); selectButton.setDisable(true); deleteButton.setDisable(true); @@ -112,8 +114,14 @@ public class ServerAliasDialog extends Dialog { serverTable.getItems().remove(serverEntry); if(serverType == ServerType.BITCOIN_CORE) { Config.get().removeRecentCoreServer(serverEntry.getServer()); + if(serverEntry.getServer().equals(Config.get().getCoreServer()) && !serverTable.getItems().isEmpty()) { + closeButton.setDisable(true); + } } else { Config.get().removeRecentElectrumServer(serverEntry.getServer()); + if(serverEntry.getServer().equals(Config.get().getElectrumServer()) && !serverTable.getItems().isEmpty()) { + closeButton.setDisable(true); + } } } });