clear connection service error message on success

This commit is contained in:
woodser 2024-05-22 08:33:43 -04:00
parent d55153bd36
commit 36f7037dde
6 changed files with 24 additions and 19 deletions

View file

@ -48,6 +48,8 @@ import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import monero.common.MoneroConnectionManager;
@ -84,6 +86,8 @@ public final class XmrConnectionService {
private final IntegerProperty numPeers = new SimpleIntegerProperty(0);
private final LongProperty chainHeight = new SimpleLongProperty(0);
private final DownloadListener downloadListener = new DownloadListener();
@Getter
private final StringProperty connectionServiceErrorMsg = new SimpleStringProperty();
private final LongProperty numUpdates = new SimpleLongProperty(0);
private Socks5ProxyProvider socks5ProxyProvider;
@ -652,6 +656,9 @@ public final class XmrConnectionService {
log.info("Successfully fetched daemon info after previous error");
lastErrorTimestamp = null;
}
// clear error message
getConnectionServiceErrorMsg().set(null);
} catch (Exception e) {
// not connected to daemon
@ -668,7 +675,7 @@ public final class XmrConnectionService {
}
// set error message
if (HavenoUtils.havenoSetup != null) HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage());
getConnectionServiceErrorMsg().set(e.getMessage());
} finally {
pollInProgress = false;
}

View file

@ -53,6 +53,7 @@ import haveno.core.alert.Alert;
import haveno.core.alert.AlertManager;
import haveno.core.alert.PrivateNotificationManager;
import haveno.core.alert.PrivateNotificationPayload;
import haveno.core.api.XmrConnectionService;
import haveno.core.api.XmrLocalNode;
import haveno.core.locale.Res;
import haveno.core.offer.OpenOfferManager;
@ -72,7 +73,6 @@ import haveno.core.user.User;
import haveno.core.util.FormattingUtils;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.xmr.setup.WalletsSetup;
import haveno.core.xmr.wallet.BtcWalletService;
import haveno.core.xmr.wallet.WalletsManager;
import haveno.core.xmr.wallet.XmrWalletService;
import haveno.network.Socks5ProxyProvider;
@ -120,7 +120,7 @@ public class HavenoSetup {
private final WalletAppSetup walletAppSetup;
private final WalletsManager walletsManager;
private final WalletsSetup walletsSetup;
private final BtcWalletService btcWalletService;
private final XmrConnectionService xmrConnectionService;
@Getter
private final XmrWalletService xmrWalletService;
private final P2PService p2PService;
@ -217,8 +217,8 @@ public class HavenoSetup {
WalletAppSetup walletAppSetup,
WalletsManager walletsManager,
WalletsSetup walletsSetup,
XmrConnectionService xmrConnectionService,
XmrWalletService xmrWalletService,
BtcWalletService btcWalletService,
P2PService p2PService,
PrivateNotificationManager privateNotificationManager,
SignedWitnessStorageService signedWitnessStorageService,
@ -242,8 +242,8 @@ public class HavenoSetup {
this.walletAppSetup = walletAppSetup;
this.walletsManager = walletsManager;
this.walletsSetup = walletsSetup;
this.xmrConnectionService = xmrConnectionService;
this.xmrWalletService = xmrWalletService;
this.btcWalletService = btcWalletService;
this.p2PService = p2PService;
this.privateNotificationManager = privateNotificationManager;
this.signedWitnessStorageService = signedWitnessStorageService;
@ -715,8 +715,8 @@ public class HavenoSetup {
return walletAppSetup.getXmrWalletSyncProgress();
}
public StringProperty getWalletServiceErrorMsg() {
return walletAppSetup.getWalletServiceErrorMsg();
public StringProperty getConnectionServiceErrorMsg() {
return xmrConnectionService.getConnectionServiceErrorMsg();
}
public StringProperty getTopErrorMsg() {

View file

@ -89,8 +89,6 @@ public class WalletAppSetup {
@Getter
private final DoubleProperty xmrWalletSyncProgress = new SimpleDoubleProperty(-1);
@Getter
private final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
@Getter
private final StringProperty xmrSplashSyncIconId = new SimpleStringProperty();
@Getter
private final StringProperty xmrInfo = new SimpleStringProperty(Res.get("mainView.footer.xmrInfo.initializing"));
@ -130,7 +128,7 @@ public class WalletAppSetup {
xmrWalletService.downloadPercentageProperty(),
xmrWalletService.walletHeightProperty(),
walletServiceException,
getWalletServiceErrorMsg(),
xmrConnectionService.getConnectionServiceErrorMsg(),
(numConnectionUpdates, walletDownloadPercentage, walletHeight, exception, errorMsg) -> {
String result;
if (exception == null && errorMsg == null) {
@ -177,16 +175,16 @@ public class WalletAppSetup {
getXmrDaemonNetworkAsString());
if (exception != null) {
if (exception instanceof TimeoutException) {
getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.timeout"));
xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.timeout"));
} else if (exception.getCause() instanceof BlockStoreException) {
if (exception.getCause().getCause() instanceof ChainFileLockedException && chainFileLockedExceptionHandler != null) {
chainFileLockedExceptionHandler.accept(Res.get("popup.warning.startupFailed.twoInstances"));
}
} else if (exception instanceof RejectedTxException) {
rejectedTxException.set((RejectedTxException) exception);
getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage()));
xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage()));
} else {
getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.connectionError", exception.getMessage()));
xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.connectionError", exception.getMessage()));
}
}
}

View file

@ -1321,7 +1321,7 @@ public class XmrWalletService {
} catch (Exception e) {
log.warn("Error initializing main wallet: " + e.getMessage());
e.printStackTrace();
HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage());
HavenoUtils.havenoSetup.getTopErrorMsg().set(e.getMessage());
throw e;
}
}

View file

@ -516,7 +516,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
xmrSplashInfo.setId("splash-error-state-msg");
xmrSplashInfo.getStyleClass().add("error-text");
};
model.getWalletServiceErrorMsg().addListener(walletServiceErrorMsgListener);
model.getConnectionServiceErrorMsg().addListener(walletServiceErrorMsgListener);
xmrSyncIndicator = new ProgressBar();
xmrSyncIndicator.setPrefWidth(305);
@ -625,7 +625,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
}
private void disposeSplashScreen() {
model.getWalletServiceErrorMsg().removeListener(walletServiceErrorMsgListener);
model.getConnectionServiceErrorMsg().removeListener(walletServiceErrorMsgListener);
model.getXmrSplashSyncIconId().removeListener(xmrSyncIconIdListener);
model.getP2pNetworkWarnMsg().removeListener(splashP2PNetworkErrorMsgListener);
@ -663,7 +663,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
//blockchainSyncIndicator.setMaxHeight(10);
//blockchainSyncIndicator.progressProperty().bind(model.getCombinedSyncProgress());
model.getWalletServiceErrorMsg().addListener((ov, oldValue, newValue) -> {
model.getConnectionServiceErrorMsg().addListener((ov, oldValue, newValue) -> {
if (newValue != null) {
xmrInfoLabel.setId("splash-error-state-msg");
xmrInfoLabel.getStyleClass().add("error-text");

View file

@ -637,8 +637,8 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener
return combinedSyncProgress;
}
StringProperty getWalletServiceErrorMsg() {
return havenoSetup.getWalletServiceErrorMsg();
StringProperty getConnectionServiceErrorMsg() {
return havenoSetup.getConnectionServiceErrorMsg();
}
StringProperty getTopErrorMsg() {