diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 0fedd67a81c..4d87e401615 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -285,6 +285,9 @@ mainView.walletServiceErrorMsg.rejectedTxException=A transaction was rejected fr mainView.networkWarning.allConnectionsLost=You lost the connection to all {0} network peers.\nMaybe you lost your internet connection or your computer was in standby mode. mainView.networkWarning.localhostBitcoinLost=You lost the connection to the localhost Bitcoin node.\nPlease restart the Bisq application to connect to other Bitcoin nodes or restart the localhost Bitcoin node. +mainView.networkWarning.clockWatcher=Your computer was asleep for {0} seconds. \ + Standby mode has been known to cause trades to fail. \ + In order to operate correctly Bisq requires that standby mode be disabled in your computer's settings. mainView.version.update=(Update available) diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index b5b36272e20..d495c7f3410 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -71,6 +71,7 @@ import bisq.network.p2p.BootstrapListener; import bisq.network.p2p.P2PService; +import bisq.common.ClockWatcher; import bisq.common.Timer; import bisq.common.UserThread; import bisq.common.app.DevEnv; @@ -139,6 +140,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { @Getter private final TorNetworkSettingsWindow torNetworkSettingsWindow; private final CorruptedStorageFileHandler corruptedStorageFileHandler; + private final ClockWatcher clockWatcher; private final Navigation navigation; @Getter @@ -184,6 +186,7 @@ public MainViewModel(BisqSetup bisqSetup, AccountAgeWitnessService accountAgeWitnessService, TorNetworkSettingsWindow torNetworkSettingsWindow, CorruptedStorageFileHandler corruptedStorageFileHandler, + ClockWatcher clockWatcher, Navigation navigation) { this.bisqSetup = bisqSetup; this.walletsSetup = walletsSetup; @@ -209,6 +212,7 @@ public MainViewModel(BisqSetup bisqSetup, this.accountAgeWitnessService = accountAgeWitnessService; this.torNetworkSettingsWindow = torNetworkSettingsWindow; this.corruptedStorageFileHandler = corruptedStorageFileHandler; + this.clockWatcher = clockWatcher; this.navigation = navigation; TxIdTextField.setPreferences(preferences); @@ -270,6 +274,7 @@ public void onSetupComplete() { setupP2PNumPeersWatcher(); setupBtcNumPeersWatcher(); + setupClockWatcherPopup(); marketPricePresentation.setup(); daoPresentation.setup(); @@ -545,6 +550,34 @@ private void setupBtcNumPeersWatcher() { }); } + private void setupClockWatcherPopup() { + ClockWatcher.Listener clockListener = new ClockWatcher.Listener() { + @Override + public void onSecondTick() { + } + + @Override + public void onMinuteTick() { + } + + @Override + public void onAwakeFromStandby(long missedMs) { + if (missedMs > TimeUnit.SECONDS.toMillis(10)) { + String key = "clockWatcherWarning"; + if (DontShowAgainLookup.showAgain(key)) { + new Popup().warning(Res.get("mainView.networkWarning.clockWatcher", missedMs / 1000)) + .actionButtonText(Res.get("shared.iUnderstand")) + .useIUnderstandButton() + .dontShowAgainId(key) + .hideCloseButton() + .show(); + } + } + } + }; + clockWatcher.addListener(clockListener); + } + private void showFirstPopupIfResyncSPVRequested() { Popup firstPopup = new Popup(); firstPopup.information(Res.get("settings.net.reSyncSPVAfterRestart")).show();