mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 23:36:00 -04:00
Allow create offer when "show all" is selected in offer book and default currency is not matching payment account currency
This commit is contained in:
parent
c021ea8ea2
commit
1c51efa704
@ -50,6 +50,7 @@ import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -211,19 +212,31 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
this.direction = direction;
|
||||
this.tradeCurrency = tradeCurrency;
|
||||
|
||||
tradeCurrencyCode.set(tradeCurrency.getCode());
|
||||
PaymentAccount account = user.findFirstPaymentAccountWithCurrency(tradeCurrency);
|
||||
if (account != null)
|
||||
if (account != null) {
|
||||
paymentAccount = account;
|
||||
this.tradeCurrency = tradeCurrency;
|
||||
} else {
|
||||
Optional<PaymentAccount> paymentAccountOptional = user.getPaymentAccounts().stream().findAny();
|
||||
if (paymentAccountOptional.isPresent()) {
|
||||
paymentAccount = paymentAccountOptional.get();
|
||||
this.tradeCurrency = paymentAccount.getSingleTradeCurrency();
|
||||
} else {
|
||||
// Should never get called as in offer view you should not be able to open a create offer view
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tradeCurrencyCode.set(this.tradeCurrency.getCode());
|
||||
|
||||
//priceFeed.setCurrencyCode(tradeCurrencyCode.get());
|
||||
|
||||
calculateVolume();
|
||||
calculateTotalToPay();
|
||||
return true;
|
||||
}
|
||||
|
||||
void onTabSelected(boolean isSelected) {
|
||||
|
@ -201,7 +201,12 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
model.initWithData(direction, tradeCurrency);
|
||||
boolean result = model.initWithData(direction, tradeCurrency);
|
||||
|
||||
if (!result) {
|
||||
log.error("Payment account set up. That should not be possible as UI does not support that case.");
|
||||
new Popup().warning("You don't have a payment account set up.").onClose(this::close).show();
|
||||
}
|
||||
|
||||
if (direction == Offer.Direction.BUY) {
|
||||
imageView.setId("image-buy-large");
|
||||
|
@ -302,10 +302,12 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
dataModel.initWithData(direction, tradeCurrency);
|
||||
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||
boolean result = dataModel.initWithData(direction, tradeCurrency);
|
||||
if (dataModel.paymentAccount != null)
|
||||
btcValidator.setMaxTradeLimitInBitcoin(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimit());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -397,7 +397,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||
}
|
||||
|
||||
public boolean hasPaymentAccountForCurrency() {
|
||||
return user.hasPaymentAccountForCurrency(selectedTradeCurrency);
|
||||
return (showAllTradeCurrenciesProperty.get() && !user.getPaymentAccounts().isEmpty()) || user.hasPaymentAccountForCurrency(selectedTradeCurrency);
|
||||
}
|
||||
|
||||
boolean hasAcceptedArbitrators() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user