mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-06 22:29:10 -04:00
Fix bug with removed currencies not updating market price combobox list
This commit is contained in:
parent
dd8d300496
commit
b7e87c51ad
2 changed files with 26 additions and 22 deletions
|
@ -721,30 +721,35 @@ public class MainViewModel implements ViewModel {
|
||||||
selectedPriceFeedComboBoxItemProperty.get().setDisplayString(newValue);
|
selectedPriceFeedComboBoxItemProperty.get().setDisplayString(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
priceFeedAllLoadedSubscription = EasyBind.subscribe(priceFeed.currenciesUpdateFlagProperty(), newPriceUpdate -> {
|
priceFeedAllLoadedSubscription = EasyBind.subscribe(priceFeed.currenciesUpdateFlagProperty(), newPriceUpdate -> setMarketPriceInItems());
|
||||||
priceFeedComboBoxItems.stream().forEach(item -> {
|
|
||||||
String currencyCode = item.currencyCode;
|
preferences.getTradeCurrenciesAsObservable().addListener((ListChangeListener<TradeCurrency>) c -> {
|
||||||
MarketPrice marketPrice = priceFeed.getMarketPrice(currencyCode);
|
UserThread.runAfter(() -> {
|
||||||
boolean useInvertedMarketPrice = preferences.getUseInvertedMarketPrice();
|
fillPriceFeedComboBoxItems();
|
||||||
String priceString;
|
setMarketPriceInItems();
|
||||||
String currencyPairString = useInvertedMarketPrice ? "BTC/" + currencyCode : currencyCode + "/BTC";
|
}, 100, TimeUnit.MILLISECONDS);
|
||||||
if (marketPrice != null) {
|
});
|
||||||
double price = marketPrice.getPrice(priceFeed.getType());
|
}
|
||||||
if (price != 0) {
|
|
||||||
double priceInverted = 1 / price;
|
private void setMarketPriceInItems() {
|
||||||
priceString = useInvertedMarketPrice ? formatter.formatMarketPrice(priceInverted, 8) : formatter.formatMarketPrice(price);
|
priceFeedComboBoxItems.stream().forEach(item -> {
|
||||||
} else {
|
String currencyCode = item.currencyCode;
|
||||||
priceString = "N/A";
|
MarketPrice marketPrice = priceFeed.getMarketPrice(currencyCode);
|
||||||
}
|
boolean useInvertedMarketPrice = preferences.getUseInvertedMarketPrice();
|
||||||
|
String priceString;
|
||||||
|
String currencyPairString = useInvertedMarketPrice ? "BTC/" + currencyCode : currencyCode + "/BTC";
|
||||||
|
if (marketPrice != null) {
|
||||||
|
double price = marketPrice.getPrice(priceFeed.getType());
|
||||||
|
if (price != 0) {
|
||||||
|
double priceInverted = 1 / price;
|
||||||
|
priceString = useInvertedMarketPrice ? formatter.formatMarketPrice(priceInverted, 8) : formatter.formatMarketPrice(price);
|
||||||
} else {
|
} else {
|
||||||
priceString = "N/A";
|
priceString = "N/A";
|
||||||
}
|
}
|
||||||
item.setDisplayString(priceString + " " + currencyPairString);
|
} else {
|
||||||
});
|
priceString = "N/A";
|
||||||
});
|
}
|
||||||
|
item.setDisplayString(priceString + " " + currencyPairString);
|
||||||
preferences.getTradeCurrenciesAsObservable().addListener((ListChangeListener<TradeCurrency>) c -> {
|
|
||||||
UserThread.runAfter(() -> fillPriceFeedComboBoxItems(), 100, TimeUnit.MILLISECONDS);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
|
||||||
fiatCurrenciesListView.setItems(fiatCurrencies);
|
fiatCurrenciesListView.setItems(fiatCurrencies);
|
||||||
fiatCurrenciesComboBox.setOnAction(e -> {
|
fiatCurrenciesComboBox.setOnAction(e -> {
|
||||||
FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
|
FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
|
||||||
log.error("setOnAction " + selectedItem);
|
|
||||||
if (selectedItem != null) {
|
if (selectedItem != null) {
|
||||||
preferences.addFiatCurrency(selectedItem);
|
preferences.addFiatCurrency(selectedItem);
|
||||||
if (allFiatCurrencies.contains(selectedItem)) {
|
if (allFiatCurrencies.contains(selectedItem)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue