mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
disable server toggle when no server is configured (url host is empty)
This commit is contained in:
parent
b15d6308bd
commit
545342dfb4
3 changed files with 12 additions and 7 deletions
|
@ -386,7 +386,7 @@ public class AppController implements Initializable {
|
|||
configureSwitchServer();
|
||||
setServerType(Config.get().getServerType());
|
||||
serverToggle.setSelected(isConnected());
|
||||
serverToggle.setDisable(Config.get().getServerType() == null);
|
||||
serverToggle.setDisable(!Config.get().hasServer());
|
||||
onlineProperty().bindBidirectional(serverToggle.selectedProperty());
|
||||
onlineProperty().addListener(new WeakChangeListener<>(serverToggleOnlineListener));
|
||||
serverToggle.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
|
||||
|
@ -1248,6 +1248,7 @@ public class AppController implements Initializable {
|
|||
PreferencesDialog preferencesDialog = new PreferencesDialog(preferenceGroup);
|
||||
preferencesDialog.showAndWait();
|
||||
configureSwitchServer();
|
||||
serverToggle.setDisable(!Config.get().hasServer());
|
||||
}
|
||||
|
||||
public void signVerifyMessage(ActionEvent event) {
|
||||
|
@ -2091,7 +2092,7 @@ public class AppController implements Initializable {
|
|||
serverToggle.getStyleClass().remove("core-server");
|
||||
}
|
||||
|
||||
serverToggle.setDisable(false);
|
||||
serverToggle.setDisable(!Config.get().hasServer());
|
||||
}
|
||||
|
||||
public void setTheme(ActionEvent event) {
|
||||
|
|
|
@ -748,11 +748,13 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
|
||||
String hostAsString = getHost(coreHost.getText());
|
||||
Integer portAsInteger = getPort(corePort.getText());
|
||||
if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
|
||||
if(hostAsString != null && !hostAsString.isEmpty() && portAsInteger != null && isValidPort(portAsInteger)) {
|
||||
Protocol protocol = portAsInteger == Protocol.HTTPS.getDefaultPort() ? Protocol.HTTPS : Protocol.HTTP;
|
||||
config.setCoreServer(new Server(protocol.toUrlString(hostAsString, portAsInteger)));
|
||||
} else if(hostAsString != null) {
|
||||
} else if(hostAsString != null && !hostAsString.isEmpty()) {
|
||||
config.setCoreServer(new Server(Protocol.HTTP.toUrlString(hostAsString)));
|
||||
} else {
|
||||
config.setCoreServer(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -781,10 +783,12 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
|
||||
String hostAsString = getHost(electrumHost.getText());
|
||||
Integer portAsInteger = getPort(electrumPort.getText());
|
||||
if(hostAsString != null && portAsInteger != null && isValidPort(portAsInteger)) {
|
||||
if(hostAsString != null && !hostAsString.isEmpty() && portAsInteger != null && isValidPort(portAsInteger)) {
|
||||
config.setElectrumServer(new Server(getProtocol().toUrlString(hostAsString, portAsInteger)));
|
||||
} else if(hostAsString != null) {
|
||||
} else if(hostAsString != null && !hostAsString.isEmpty()) {
|
||||
config.setElectrumServer(new Server(getProtocol().toUrlString(hostAsString)));
|
||||
} else {
|
||||
config.setElectrumServer(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@
|
|||
<ComboBox fx:id="recentElectrumServers" />
|
||||
<ComboBoxTextField fx:id="electrumHost" promptText="e.g. 127.0.0.1 or Tor hostname (.onion)" comboProperty="$recentElectrumServers" />
|
||||
</StackPane>
|
||||
<TextField fx:id="electrumPort" promptText="e.g. 50002" maxWidth="120" />
|
||||
<TextField fx:id="electrumPort" promptText="e.g. 50001" maxWidth="120" />
|
||||
</Field>
|
||||
<Field text="Use SSL:">
|
||||
<UnlabeledToggleSwitch fx:id="electrumUseSsl"/>
|
||||
|
|
Loading…
Reference in a new issue