mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 14:44:10 +01:00
Fix handling of preferred currency
This commit is contained in:
parent
108255bf8e
commit
e43a8aed36
@ -53,6 +53,7 @@ import javax.inject.Named;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -131,7 +132,25 @@ public class BtcOfferBookViewModel extends OfferBookViewModel {
|
||||
|
||||
@Override
|
||||
TradeCurrency getDefaultTradeCurrency() {
|
||||
return GlobalSettings.getDefaultTradeCurrency();
|
||||
TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency();
|
||||
|
||||
if (CurrencyUtil.isFiatCurrency(defaultTradeCurrency.getCode())) {
|
||||
return defaultTradeCurrency;
|
||||
}
|
||||
|
||||
ObservableList<TradeCurrency> tradeCurrencies = FXCollections.observableArrayList(getTradeCurrencies());
|
||||
if (!tradeCurrencies.isEmpty()) {
|
||||
// drop show all entry and select first currency with payment account available
|
||||
tradeCurrencies.remove(0);
|
||||
List<TradeCurrency> sortedList = tradeCurrencies.stream().sorted((o1, o2) ->
|
||||
Boolean.compare(!hasPaymentAccountForCurrency(o1),
|
||||
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList());
|
||||
return sortedList.get(0);
|
||||
} else {
|
||||
return CurrencyUtil.getMainFiatCurrencies().stream().sorted((o1, o2) ->
|
||||
Boolean.compare(!hasPaymentAccountForCurrency(o1),
|
||||
!hasPaymentAccountForCurrency(o2))).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import bisq.core.btc.setup.WalletsSetup;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.locale.CryptoCurrency;
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.GlobalSettings;
|
||||
import bisq.core.locale.TradeCurrency;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OfferDirection;
|
||||
@ -133,6 +134,14 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
|
||||
|
||||
@Override
|
||||
TradeCurrency getDefaultTradeCurrency() {
|
||||
TradeCurrency defaultTradeCurrency = GlobalSettings.getDefaultTradeCurrency();
|
||||
|
||||
if (!CurrencyUtil.isFiatCurrency(defaultTradeCurrency.getCode()) &&
|
||||
!defaultTradeCurrency.equals(GUIUtil.BSQ) &&
|
||||
!defaultTradeCurrency.equals(GUIUtil.TOP_ALTCOIN)) {
|
||||
return defaultTradeCurrency;
|
||||
}
|
||||
|
||||
ObservableList<TradeCurrency> tradeCurrencies = FXCollections.observableArrayList(getTradeCurrencies());
|
||||
if (!tradeCurrencies.isEmpty()) {
|
||||
// drop show all entry and select first currency with payment account available
|
||||
|
Loading…
Reference in New Issue
Block a user