Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a warning if PC has been in sleep mode #5719

Merged
merged 1 commit into from Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
33 changes: 33 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -184,6 +186,7 @@ public MainViewModel(BisqSetup bisqSetup,
AccountAgeWitnessService accountAgeWitnessService,
TorNetworkSettingsWindow torNetworkSettingsWindow,
CorruptedStorageFileHandler corruptedStorageFileHandler,
ClockWatcher clockWatcher,
Navigation navigation) {
this.bisqSetup = bisqSetup;
this.walletsSetup = walletsSetup;
Expand All @@ -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);
Expand Down Expand Up @@ -270,6 +274,7 @@ public void onSetupComplete() {

setupP2PNumPeersWatcher();
setupBtcNumPeersWatcher();
setupClockWatcherPopup();

marketPricePresentation.setup();
daoPresentation.setup();
Expand Down Expand Up @@ -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();
Expand Down