handle mode and startup config better

This commit is contained in:
Craig Raw 2021-01-13 08:11:10 +02:00
parent 94da3b37b6
commit 7ae74e3000
4 changed files with 6 additions and 2 deletions

View file

@ -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());
}

View file

@ -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);

View file

@ -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);
}

View file

@ -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 -> {