Browse Source

handle mode and startup config better

bwt
Craig Raw 4 years ago
parent
commit
7ae74e3000
  1. 3
      src/main/java/com/sparrowwallet/sparrow/AppController.java
  2. 1
      src/main/java/com/sparrowwallet/sparrow/AppServices.java
  3. 2
      src/main/java/com/sparrowwallet/sparrow/MainApp.java
  4. 2
      src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java

3
src/main/java/com/sparrowwallet/sparrow/AppController.java

@ -230,6 +230,9 @@ public class AppController implements Initializable {
onlineProperty().addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> setServerToggleTooltip(getCurrentBlockHeight()));
});
serverToggle.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
Config.get().setMode(serverToggle.isSelected() ? Mode.ONLINE : Mode.OFFLINE);
});
openTransactionIdItem.disableProperty().bind(onlineProperty().not());
}

1
src/main/java/com/sparrowwallet/sparrow/AppServices.java

@ -84,7 +84,6 @@ public class AppServices {
private final ChangeListener<Boolean> onlineServicesListener = new ChangeListener<>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean online) {
Config.get().setMode(online ? Mode.ONLINE : Mode.OFFLINE);
if(online) {
restartService(connectionService);

2
src/main/java/com/sparrowwallet/sparrow/MainApp.java

@ -62,7 +62,7 @@ public class MainApp extends Application {
}
}
if(Config.get().getServerType() == null) {
if(Config.get().getServerType() == null && Config.get().getCoreServer() == null && Config.get().getElectrumServer() != null) {
Config.get().setServerType(ServerType.ELECTRUM_SERVER);
}

2
src/main/java/com/sparrowwallet/sparrow/preferences/ServerPreferencesController.java

@ -5,6 +5,7 @@ import com.google.common.net.HostAndPort;
import com.sparrowwallet.drongo.Network;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.Mode;
import com.sparrowwallet.sparrow.control.TextFieldValidator;
import com.sparrowwallet.sparrow.control.UnlabeledToggleSwitch;
import com.sparrowwallet.sparrow.event.*;
@ -371,6 +372,7 @@ public class ServerPreferencesController extends PreferencesDetailController {
ConnectionEvent connectionEvent = (ConnectionEvent)connectionService.getValue();
showConnectionSuccess(connectionEvent.getServerVersion(), connectionEvent.getServerBanner());
getMasterController().reconnectOnClosingProperty().set(true);
Config.get().setMode(Mode.ONLINE);
connectionService.cancel();
});
connectionService.setOnFailed(workerStateEvent -> {

Loading…
Cancel
Save