populate trigger price and extra info on duplicate or edit offer

This commit is contained in:
woodser 2025-04-04 13:55:25 -04:00 committed by GitHub
parent 9bd4f70d02
commit 9668dd2369
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 7 deletions

View File

@ -262,6 +262,7 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
buyerAsTakerWithoutDepositSlider.setSelected(model.dataModel.getBuyerAsTakerWithoutDeposit().get());
triggerPriceInputTextField.setText(model.triggerPrice.get());
extraInfoTextArea.setText(model.dataModel.extraInfo.get());
}
}

View File

@ -501,7 +501,10 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
};
extraInfoStringListener = (ov, oldValue, newValue) -> {
onExtraInfoTextAreaChanged();
if (newValue != null) {
extraInfo.set(newValue);
onExtraInfoTextAreaChanged();
}
};
isWalletFundedListener = (ov, oldValue, newValue) -> updateButtonDisableState();
@ -582,6 +585,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
dataModel.getVolume().removeListener(volumeListener);
dataModel.getSecurityDepositPct().removeListener(securityDepositAsDoubleListener);
dataModel.getBuyerAsTakerWithoutDeposit().removeListener(buyerAsTakerWithoutDepositListener);
dataModel.getExtraInfo().removeListener(extraInfoStringListener);
//dataModel.feeFromFundingTxProperty.removeListener(feeFromFundingTxListener);
dataModel.getIsXmrWalletFunded().removeListener(isWalletFundedListener);
@ -843,7 +847,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
extraInfoValidationResult.set(getExtraInfoValidationResult());
updateButtonDisableState();
if (extraInfoValidationResult.get().isValid) {
dataModel.setExtraInfo(extraInfo.get());
setExtraInfoToModel();
}
}

View File

@ -26,6 +26,7 @@ import haveno.core.locale.TradeCurrency;
import haveno.core.offer.CreateOfferService;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferUtil;
import haveno.core.offer.OpenOffer;
import haveno.core.offer.OpenOfferManager;
import haveno.core.payment.PaymentAccount;
import haveno.core.provider.price.PriceFeedService;
@ -89,13 +90,15 @@ class DuplicateOfferDataModel extends MutableOfferDataModel {
setPrice(offer.getPrice());
setVolume(offer.getVolume());
setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
setBuyerAsTakerWithoutDeposit(offer.hasBuyerAsTakerWithoutDeposit());
setSecurityDepositPct(getSecurityAsPercent(offer));
if (offer.isUseMarketBasedPrice()) {
setMarketPriceMarginPct(offer.getMarketPriceMarginPct());
}
setBuyerAsTakerWithoutDeposit(offer.hasBuyerAsTakerWithoutDeposit());
setSecurityDepositPct(getSecurityAsPercent(offer));
setExtraInfo(offer.getOfferExtraInfo());
OpenOffer openOffer = openOfferManager.getOpenOffer(offer.getId()).orElse(null);
if (openOffer != null) setTriggerPrice(openOffer.getTriggerPrice());
}
private double getSecurityAsPercent(Offer offer) {

View File

@ -29,6 +29,7 @@ import haveno.core.payment.validation.XmrValidator;
import haveno.core.provider.price.PriceFeedService;
import haveno.core.user.Preferences;
import haveno.core.util.FormattingUtils;
import haveno.core.util.PriceUtil;
import haveno.core.util.coin.CoinFormatter;
import haveno.core.util.validation.AmountValidator4Decimals;
import haveno.core.util.validation.AmountValidator8Decimals;
@ -76,6 +77,16 @@ class DuplicateOfferViewModel extends MutableOfferViewModel<DuplicateOfferDataMo
public void activate() {
super.activate();
dataModel.populateData(offer);
long triggerPriceAsLong = dataModel.getTriggerPrice();
dataModel.setTriggerPrice(triggerPriceAsLong);
if (triggerPriceAsLong > 0) {
triggerPrice.set(PriceUtil.formatMarketPrice(triggerPriceAsLong, dataModel.getCurrencyCode()));
} else {
triggerPrice.set("");
}
onTriggerPriceTextFieldChanged();
triggerFocusOutOnAmountFields();
onFocusOutPriceAsPercentageTextField(true, false);
}

View File

@ -137,6 +137,9 @@ class EditOfferDataModel extends MutableOfferDataModel {
securityDepositPct.set(securityDepositPercent);
allowAmountUpdate = false;
triggerPrice = openOffer.getTriggerPrice();
extraInfo.set(offer.getOfferExtraInfo());
}
@Override
@ -164,10 +167,10 @@ class EditOfferDataModel extends MutableOfferDataModel {
setPrice(offer.getPrice());
setVolume(offer.getVolume());
setUseMarketBasedPrice(offer.isUseMarketBasedPrice());
setTriggerPrice(openOffer.getTriggerPrice());
if (offer.isUseMarketBasedPrice()) {
setMarketPriceMarginPct(offer.getMarketPriceMarginPct());
}
setTriggerPrice(openOffer.getTriggerPrice());
setExtraInfo(offer.getOfferExtraInfo());
}