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

View file

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

View file

@ -89,8 +89,6 @@ public class WalletAppSetup {
@Getter @Getter
private final DoubleProperty xmrWalletSyncProgress = new SimpleDoubleProperty(-1); private final DoubleProperty xmrWalletSyncProgress = new SimpleDoubleProperty(-1);
@Getter @Getter
private final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
@Getter
private final StringProperty xmrSplashSyncIconId = new SimpleStringProperty(); private final StringProperty xmrSplashSyncIconId = new SimpleStringProperty();
@Getter @Getter
private final StringProperty xmrInfo = new SimpleStringProperty(Res.get("mainView.footer.xmrInfo.initializing")); private final StringProperty xmrInfo = new SimpleStringProperty(Res.get("mainView.footer.xmrInfo.initializing"));
@ -130,7 +128,7 @@ public class WalletAppSetup {
xmrWalletService.downloadPercentageProperty(), xmrWalletService.downloadPercentageProperty(),
xmrWalletService.walletHeightProperty(), xmrWalletService.walletHeightProperty(),
walletServiceException, walletServiceException,
getWalletServiceErrorMsg(), xmrConnectionService.getConnectionServiceErrorMsg(),
(numConnectionUpdates, walletDownloadPercentage, walletHeight, exception, errorMsg) -> { (numConnectionUpdates, walletDownloadPercentage, walletHeight, exception, errorMsg) -> {
String result; String result;
if (exception == null && errorMsg == null) { if (exception == null && errorMsg == null) {
@ -177,16 +175,16 @@ public class WalletAppSetup {
getXmrDaemonNetworkAsString()); getXmrDaemonNetworkAsString());
if (exception != null) { if (exception != null) {
if (exception instanceof TimeoutException) { 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) { } else if (exception.getCause() instanceof BlockStoreException) {
if (exception.getCause().getCause() instanceof ChainFileLockedException && chainFileLockedExceptionHandler != null) { if (exception.getCause().getCause() instanceof ChainFileLockedException && chainFileLockedExceptionHandler != null) {
chainFileLockedExceptionHandler.accept(Res.get("popup.warning.startupFailed.twoInstances")); chainFileLockedExceptionHandler.accept(Res.get("popup.warning.startupFailed.twoInstances"));
} }
} else if (exception instanceof RejectedTxException) { } else if (exception instanceof RejectedTxException) {
rejectedTxException.set((RejectedTxException) exception); rejectedTxException.set((RejectedTxException) exception);
getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage())); xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage()));
} else { } 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) { } catch (Exception e) {
log.warn("Error initializing main wallet: " + e.getMessage()); log.warn("Error initializing main wallet: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage()); HavenoUtils.havenoSetup.getTopErrorMsg().set(e.getMessage());
throw e; throw e;
} }
} }

View file

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

View file

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