mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-05 21:24:19 -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
4 changed files with 28 additions and 8 deletions
|
@ -50,6 +50,7 @@ import org.bitcoinj.utils.Fiat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -211,19 +212,31 @@ class CreateOfferDataModel extends ActivatableDataModel {
|
||||||
// API
|
// API
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
this.tradeCurrency = tradeCurrency;
|
|
||||||
|
|
||||||
tradeCurrencyCode.set(tradeCurrency.getCode());
|
|
||||||
PaymentAccount account = user.findFirstPaymentAccountWithCurrency(tradeCurrency);
|
PaymentAccount account = user.findFirstPaymentAccountWithCurrency(tradeCurrency);
|
||||||
if (account != null)
|
if (account != null) {
|
||||||
paymentAccount = account;
|
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());
|
//priceFeed.setCurrencyCode(tradeCurrencyCode.get());
|
||||||
|
|
||||||
calculateVolume();
|
calculateVolume();
|
||||||
calculateTotalToPay();
|
calculateTotalToPay();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onTabSelected(boolean isSelected) {
|
void onTabSelected(boolean isSelected) {
|
||||||
|
|
|
@ -201,7 +201,12 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
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) {
|
if (direction == Offer.Direction.BUY) {
|
||||||
imageView.setId("image-buy-large");
|
imageView.setId("image-buy-large");
|
||||||
|
|
|
@ -302,10 +302,12 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
|
||||||
// API
|
// API
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
boolean initWithData(Offer.Direction direction, TradeCurrency tradeCurrency) {
|
||||||
dataModel.initWithData(direction, tradeCurrency);
|
boolean result = dataModel.initWithData(direction, tradeCurrency);
|
||||||
if (dataModel.paymentAccount != null)
|
if (dataModel.paymentAccount != null)
|
||||||
btcValidator.setMaxTradeLimitInBitcoin(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimit());
|
btcValidator.setMaxTradeLimitInBitcoin(dataModel.paymentAccount.getPaymentMethod().getMaxTradeLimit());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPaymentAccountForCurrency() {
|
public boolean hasPaymentAccountForCurrency() {
|
||||||
return user.hasPaymentAccountForCurrency(selectedTradeCurrency);
|
return (showAllTradeCurrenciesProperty.get() && !user.getPaymentAccounts().isEmpty()) || user.hasPaymentAccountForCurrency(selectedTradeCurrency);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasAcceptedArbitrators() {
|
boolean hasAcceptedArbitrators() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue