diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/PriceInput.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/PriceInput.java index aedf091965..8fd6f1e86f 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/PriceInput.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/PriceInput.java @@ -195,6 +195,7 @@ private Model() { public void reset() { priceQuote.set(null); + priceString.set(null); market = null; isFocused = false; description.set(null); diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/market/TradeWizardMarketController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/market/TradeWizardMarketController.java index fb518dbf3f..796ee5cf09 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/market/TradeWizardMarketController.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/market/TradeWizardMarketController.java @@ -17,6 +17,7 @@ package bisq.desktop.main.content.bisq_easy.trade_wizard.market; +import bisq.bonded_roles.market_price.MarketPriceService; import bisq.chat.ChatMessage; import bisq.chat.ChatService; import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookChannel; @@ -48,6 +49,7 @@ public class TradeWizardMarketController implements Controller { private final Runnable onNextHandler; private final BisqEasyOfferbookChannelService bisqEasyOfferbookChannelService; private final BisqEasyOfferbookSelectionService bisqEasyOfferbookSelectionService; + private final MarketPriceService marketPriceService; private Subscription searchTextPin; public TradeWizardMarketController(ServiceProvider serviceProvider, Runnable onNextHandler) { @@ -55,6 +57,7 @@ public TradeWizardMarketController(ServiceProvider serviceProvider, Runnable onN chatService = serviceProvider.getChatService(); bisqEasyOfferbookChannelService = chatService.getBisqEasyOfferbookChannelService(); bisqEasyOfferbookSelectionService = chatService.getBisqEasyOfferbookChannelSelectionService(); + marketPriceService = serviceProvider.getBondedRolesService().getMarketPriceService(); model = new TradeWizardMarketModel(); view = new TradeWizardMarketView(model, this); } @@ -88,6 +91,7 @@ public void onActivate() { } model.getListItems().setAll(MarketRepository.getAllFiatMarkets().stream() + .filter(market -> marketPriceService.getMarketPriceByCurrencyMap().containsKey(market)) .map(market -> { Set allMessages = bisqEasyOfferbookChannelService.getChannels().stream() .filter(channel -> channel.getMarket().equals(market)) diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceController.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceController.java index 0f5e94dc9b..387d17b031 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceController.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceController.java @@ -72,6 +72,7 @@ public ReadOnlyObjectProperty getPriceSpec() { } public void reset() { + priceInput.reset(); model.reset(); } @@ -164,18 +165,15 @@ private void applyPercentageFromQuote(PriceQuote priceQuote) { model.getPercentageAsString().set(formatToPercentWithSymbol(percentage)); } - //todo add validator and give feedback private boolean isQuoteValid(PriceQuote priceQuote) { double percentage = getPercentage(priceQuote); - if (percentage >= -0.1 && percentage <= 0.5) { - return true; - } - return false; + return percentage >= -0.1 && percentage <= 0.5; } private double getPercentage(PriceQuote priceQuote) { - Optional optionalPercentage = PriceSpecUtil.createFloatPriceSpec(marketPriceService, priceQuote).map(FloatPriceSpec::getPercentage); + Optional optionalPercentage = PriceSpecUtil.createFloatPriceSpec(marketPriceService, priceQuote) + .map(FloatPriceSpec::getPercentage); if (optionalPercentage.isEmpty()) { log.error("optionalPercentage not present"); } diff --git a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceView.java b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceView.java index 033cb4f4f5..1cc24e2d8e 100644 --- a/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceView.java +++ b/apps/desktop/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/trade_wizard/price/TradeWizardPriceView.java @@ -46,6 +46,7 @@ public class TradeWizardPriceView extends View findFixPriceSpec(PriceSpec priceSpec) { - return priceSpec instanceof FixPriceSpec ? - Optional.of((FixPriceSpec) priceSpec) : - Optional.empty(); + return priceSpec instanceof FixPriceSpec + ? Optional.of((FixPriceSpec) priceSpec) + : Optional.empty(); } public static Optional findFloatPriceSpec(PriceSpec priceSpec) { - return priceSpec instanceof FloatPriceSpec ? - Optional.of((FloatPriceSpec) priceSpec) : - Optional.empty(); + return priceSpec instanceof FloatPriceSpec + ? Optional.of((FloatPriceSpec) priceSpec) + : Optional.empty(); } public static Optional findMarketPriceSpec(PriceSpec priceSpec) { - return priceSpec instanceof MarketPriceSpec ? - Optional.of((MarketPriceSpec) priceSpec) : - Optional.empty(); + return priceSpec instanceof MarketPriceSpec + ? Optional.of((MarketPriceSpec) priceSpec) + : Optional.empty(); } public static Optional createFloatPriceSpec(MarketPriceService marketPriceService, PriceQuote priceQuote) { @@ -53,4 +53,4 @@ public static Optional createFloatPriceSpec(MarketPriceService m .map(FloatPriceSpec::new) .findAny(); } -} \ No newline at end of file +}