From f401f72896b8aee792c120ddae098febe8daaaef Mon Sep 17 00:00:00 2001 From: Sowik Date: Tue, 5 Sep 2023 15:27:36 +0300 Subject: [PATCH] When amount is below minimum for order, show warning on the text field instead of popup. --- .../main/offer/MutableOfferViewModel.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java index 39928ec91e..0b7f23dda7 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java @@ -687,13 +687,20 @@ public abstract class MutableOfferViewModel ext if (minAmount.get() != null) minAmountValidationResult.set(isXmrInputValid(minAmount.get())); } else if (amount.get() != null && xmrValidator.getMaxTradeLimit() != null && xmrValidator.getMaxTradeLimit().longValueExact() == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.longValueExact()) { - amount.set(HavenoUtils.formatXmr(xmrValidator.getMaxTradeLimit())); - boolean isBuy = dataModel.getDirection() == OfferDirection.BUY; - new Popup().information(Res.get(isBuy ? "popup.warning.tradeLimitDueAccountAgeRestriction.buyer" : "popup.warning.tradeLimitDueAccountAgeRestriction.seller", - HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true), - Res.get("offerbook.warning.newVersionAnnouncement"))) - .width(900) - .show(); + + if (Double.parseDouble(amount.get()) < HavenoUtils.atomicUnitsToXmr(Restrictions.getMinTradeAmount())){ + amountValidationResult.set(result); + } + else{ + amount.set(HavenoUtils.formatXmr(xmrValidator.getMaxTradeLimit())); + boolean isBuy = dataModel.getDirection() == OfferDirection.BUY; + new Popup().information(Res.get(isBuy ? "popup.warning.tradeLimitDueAccountAgeRestriction.buyer" : "popup.warning.tradeLimitDueAccountAgeRestriction.seller", + HavenoUtils.formatXmr(OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT, true), + Res.get("offerbook.warning.newVersionAnnouncement"))) + .width(900) + .show(); + } + } // We want to trigger a recalculation of the volume UserThread.execute(() -> {