From f0471bccfd02e7349d4a8adecf6dd83505e66102 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 23 Sep 2018 13:48:01 -0500 Subject: [PATCH] Warn user when closing with open offers Fixes https://github.com/bisq-network/bisq/issues/1663 --- .../resources/i18n/displayStrings.properties | 7 +++++ .../main/java/bisq/desktop/app/BisqApp.java | 26 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 8a9291db80..bb7a625a46 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1787,6 +1787,13 @@ popup.info.securityDepositInfo=To ensure that both traders follow the trade prot popup.info.cashDepositInfo=Please be sure that you have a bank branch in your area to be able to make the cash deposit.\n\ The bank ID (BIC/SWIFT) of the seller''s bank is: {0}. popup.info.cashDepositInfo.confirm=I confirm that I can make the deposit +popup.info.shutDownWithOpenOffers=You try to shut down Bisq with open offers. \n\n\ + When you shut down Bisq your offers are not available anymore in the P2P network. \ + The next time you start up Bisq again your offers will get re-published to the P2P network.\n\n\ + If you want to keep your offers online you need to leave Bisq running. \ + Be sure that your computer does not switch to standby mode when not active. \ + Standby mode of the monitor is not a problem. + popup.privateNotification.headline=Important private notification! diff --git a/desktop/src/main/java/bisq/desktop/app/BisqApp.java b/desktop/src/main/java/bisq/desktop/app/BisqApp.java index 10a74df32b..97e450c17f 100644 --- a/desktop/src/main/java/bisq/desktop/app/BisqApp.java +++ b/desktop/src/main/java/bisq/desktop/app/BisqApp.java @@ -39,6 +39,8 @@ import bisq.core.btc.wallet.BtcWalletService; import bisq.core.btc.wallet.WalletsManager; import bisq.core.filter.FilterManager; import bisq.core.locale.Res; +import bisq.core.offer.OpenOfferManager; +import bisq.core.user.Preferences; import bisq.common.UserThread; import bisq.common.app.DevEnv; @@ -212,7 +214,7 @@ public class BisqApp extends Application implements UncaughtExceptionHandler { stage.setOnCloseRequest(event -> { event.consume(); - stop(); + shutDownByUser(); }); // configure the primary stage @@ -247,7 +249,7 @@ public class BisqApp extends Application implements UncaughtExceptionHandler { scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEvent -> { if (Utilities.isCtrlPressed(KeyCode.W, keyEvent) || Utilities.isCtrlPressed(KeyCode.Q, keyEvent)) { - stop(); + shutDownByUser(); } else { if (Utilities.isAltOrCtrlPressed(KeyCode.E, keyEvent)) { showBtcEmergencyWalletPopup(injector); @@ -280,6 +282,26 @@ public class BisqApp extends Application implements UncaughtExceptionHandler { }); } + private void shutDownByUser() { + if (injector.getInstance(OpenOfferManager.class).getObservableList().isEmpty()) { + // No open offers, so no need to show the popup. + stop(); + return; + } + + // We show a popup to inform user that open offers will be removed if Bisq is not running. + String key = "showOpenOfferWarnPopupAtShutDown"; + if (injector.getInstance(Preferences.class).showAgain(key)) { + new Popup<>().information(Res.get("popup.info.shutDownWithOpenOffers")) + .dontShowAgainId(key) + .useShutDownButton() + .closeButtonText(Res.get("shared.cancel")) + .show(); + } else { + stop(); + } + } + private void showSendAlertMessagePopup(Injector injector) { AlertManager alertManager = injector.getInstance(AlertManager.class); boolean useDevPrivilegeKeys = injector.getInstance(Key.get(Boolean.class, Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)));