diff --git a/desktop/src/main/java/bisq/desktop/main/MainView.java b/desktop/src/main/java/bisq/desktop/main/MainView.java index ff09adc716a..9dfcd6325e6 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainView.java +++ b/desktop/src/main/java/bisq/desktop/main/MainView.java @@ -254,11 +254,12 @@ protected void initialize() { protected Tooltip computeValue() { String tooltipText = Res.get("mainView.balance.available"); try { + String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode(); double availableBalance = Double.parseDouble( model.getAvailableBalance().getValue().replace("BTC", "")); - double marketPrice = Double.parseDouble(model.getMarketPrice().getValue()); + double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue()); tooltipText += "\n" + currencyFormat.format(availableBalance * marketPrice) + - " " + model.getPreferences().getPreferredTradeCurrency().getCode(); + " " + preferredTradeCurrency; } catch (NullPointerException | NumberFormatException e) { // Either the balance or market price is not available yet } @@ -278,11 +279,12 @@ protected Tooltip computeValue() { protected Tooltip computeValue() { String tooltipText = Res.get("mainView.balance.reserved"); try { + String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode(); double reservedBalance = Double.parseDouble( model.getReservedBalance().getValue().replace("BTC", "")); - double marketPrice = Double.parseDouble(model.getMarketPrice().getValue()); + double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue()); tooltipText += "\n" + currencyFormat.format(reservedBalance * marketPrice) + - " " + model.getPreferences().getPreferredTradeCurrency().getCode(); + " " + preferredTradeCurrency; } catch (NullPointerException | NumberFormatException e) { // Either the balance or market price is not available yet } @@ -302,11 +304,12 @@ protected Tooltip computeValue() { protected Tooltip computeValue() { String tooltipText = Res.get("mainView.balance.locked"); try { + String preferredTradeCurrency = model.getPreferences().getPreferredTradeCurrency().getCode(); double lockedBalance = Double.parseDouble( model.getLockedBalance().getValue().replace("BTC", "")); - double marketPrice = Double.parseDouble(model.getMarketPrice().getValue()); + double marketPrice = Double.parseDouble(model.getMarketPrice(preferredTradeCurrency).getValue()); tooltipText += "\n" + currencyFormat.format(lockedBalance * marketPrice) + - " " + model.getPreferences().getPreferredTradeCurrency().getCode(); + " " + preferredTradeCurrency; } catch (NullPointerException | NumberFormatException e) { // Either the balance or market price is not available yet } diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 70726c52ac7..786d955134c 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -613,6 +613,10 @@ StringProperty getMarketPrice() { return marketPricePresentation.getMarketPrice(); } + StringProperty getMarketPrice(String currencyCode) { + return marketPricePresentation.getMarketPrice(currencyCode); + } + public ObservableList getPriceFeedComboBoxItems() { return marketPricePresentation.getPriceFeedComboBoxItems(); } diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java index 3c1c864ed60..d6e4f6f5627 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/MarketPricePresentation.java @@ -242,4 +242,14 @@ public IntegerProperty getMarketPriceUpdated() { public StringProperty getMarketPrice() { return marketPrice; } + + public StringProperty getMarketPrice(String currencyCode) { + SimpleStringProperty marketPrice = new SimpleStringProperty(Res.get("shared.na")); + try { + marketPrice.set(String.valueOf(priceFeedService.getMarketPrice(currencyCode).getPrice())); + } catch (NullPointerException e) { + // Market price is not available yet + } + return marketPrice; + } }