mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Fix bug with removed currencies not updating market price combobox list
This commit is contained in:
parent
dd8d300496
commit
b7e87c51ad
@ -721,30 +721,35 @@ public class MainViewModel implements ViewModel {
|
||||
selectedPriceFeedComboBoxItemProperty.get().setDisplayString(newValue);
|
||||
});
|
||||
|
||||
priceFeedAllLoadedSubscription = EasyBind.subscribe(priceFeed.currenciesUpdateFlagProperty(), newPriceUpdate -> {
|
||||
priceFeedComboBoxItems.stream().forEach(item -> {
|
||||
String currencyCode = item.currencyCode;
|
||||
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 {
|
||||
priceString = "N/A";
|
||||
}
|
||||
priceFeedAllLoadedSubscription = EasyBind.subscribe(priceFeed.currenciesUpdateFlagProperty(), newPriceUpdate -> setMarketPriceInItems());
|
||||
|
||||
preferences.getTradeCurrenciesAsObservable().addListener((ListChangeListener<TradeCurrency>) c -> {
|
||||
UserThread.runAfter(() -> {
|
||||
fillPriceFeedComboBoxItems();
|
||||
setMarketPriceInItems();
|
||||
}, 100, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
private void setMarketPriceInItems() {
|
||||
priceFeedComboBoxItems.stream().forEach(item -> {
|
||||
String currencyCode = item.currencyCode;
|
||||
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 {
|
||||
priceString = "N/A";
|
||||
}
|
||||
item.setDisplayString(priceString + " " + currencyPairString);
|
||||
});
|
||||
});
|
||||
|
||||
preferences.getTradeCurrenciesAsObservable().addListener((ListChangeListener<TradeCurrency>) c -> {
|
||||
UserThread.runAfter(() -> fillPriceFeedComboBoxItems(), 100, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
priceString = "N/A";
|
||||
}
|
||||
item.setDisplayString(priceString + " " + currencyPairString);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
|
||||
fiatCurrenciesListView.setItems(fiatCurrencies);
|
||||
fiatCurrenciesComboBox.setOnAction(e -> {
|
||||
FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
|
||||
log.error("setOnAction " + selectedItem);
|
||||
if (selectedItem != null) {
|
||||
preferences.addFiatCurrency(selectedItem);
|
||||
if (allFiatCurrencies.contains(selectedItem)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user