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

Fix BTC valuation popups #3539

Merged
merged 1 commit into from
Nov 1, 2019
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
15 changes: 9 additions & 6 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ StringProperty getMarketPrice() {
return marketPricePresentation.getMarketPrice();
}

StringProperty getMarketPrice(String currencyCode) {
return marketPricePresentation.getMarketPrice(currencyCode);
}

public ObservableList<PriceFeedComboBoxItem> getPriceFeedComboBoxItems() {
return marketPricePresentation.getPriceFeedComboBoxItems();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}