Merge pull request #2205 from j3ko/hotfix/take_offer

Update offer button state on account change
This commit is contained in:
Christoph Atteneder 2019-01-07 08:51:40 +01:00 committed by GitHub
commit 75e9e99d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -178,7 +178,7 @@ class TakeOfferDataModel extends OfferDataModel {
ObservableList<PaymentAccount> possiblePaymentAccounts = getPossiblePaymentAccounts(); ObservableList<PaymentAccount> possiblePaymentAccounts = getPossiblePaymentAccounts();
checkArgument(!possiblePaymentAccounts.isEmpty(), "possiblePaymentAccounts.isEmpty()"); checkArgument(!possiblePaymentAccounts.isEmpty(), "possiblePaymentAccounts.isEmpty()");
paymentAccount = possiblePaymentAccounts.get(0); paymentAccount = getLastSelectedPaymentAccount();
long myLimit = accountAgeWitnessService.getMyTradeLimit(paymentAccount, getCurrencyCode()); long myLimit = accountAgeWitnessService.getMyTradeLimit(paymentAccount, getCurrencyCode());
this.amount.set(Coin.valueOf(Math.min(offer.getAmount().value, myLimit))); this.amount.set(Coin.valueOf(Math.min(offer.getAmount().value, myLimit)));
@ -411,7 +411,7 @@ class TakeOfferDataModel extends OfferDataModel {
this.paymentAccount = paymentAccount; this.paymentAccount = paymentAccount;
long myLimit = accountAgeWitnessService.getMyTradeLimit(paymentAccount, getCurrencyCode()); long myLimit = accountAgeWitnessService.getMyTradeLimit(paymentAccount, getCurrencyCode());
this.amount.set(Coin.valueOf(Math.min(amount.get().value, myLimit))); this.amount.set(Coin.valueOf(Math.max(offer.getMinAmount().value, Math.min(amount.get().value, myLimit))));
preferences.setTakeOfferSelectedPaymentAccountId(paymentAccount.getId()); preferences.setTakeOfferSelectedPaymentAccountId(paymentAccount.getId());
} }

View file

@ -282,9 +282,10 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get()); volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get());
if (model.getPossiblePaymentAccounts().size() > 1) { if (model.getPossiblePaymentAccounts().size() > 1) {
PaymentAccount lastPaymentAccount = model.getLastSelectedPaymentAccount();
paymentAccountsComboBox.setItems(model.getPossiblePaymentAccounts()); paymentAccountsComboBox.setItems(model.getPossiblePaymentAccounts());
paymentAccountsComboBox.getSelectionModel().select(model.getLastSelectedPaymentAccount()); paymentAccountsComboBox.getSelectionModel().select(lastPaymentAccount);
model.onPaymentAccountSelected(lastPaymentAccount);
paymentAccountTitledGroupBg.setText(Res.get("shared.selectTradingAccount")); paymentAccountTitledGroupBg.setText(Res.get("shared.selectTradingAccount"));
// TODO if we have multiple payment accounts we should show some info/warning to // TODO if we have multiple payment accounts we should show some info/warning to

View file

@ -246,6 +246,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
public void onPaymentAccountSelected(PaymentAccount paymentAccount) { public void onPaymentAccountSelected(PaymentAccount paymentAccount) {
dataModel.onPaymentAccountSelected(paymentAccount); dataModel.onPaymentAccountSelected(paymentAccount);
btcValidator.setMaxTradeLimit(Coin.valueOf(Math.min(dataModel.getMaxTradeLimit(), offer.getAmount().value))); btcValidator.setMaxTradeLimit(Coin.valueOf(Math.min(dataModel.getMaxTradeLimit(), offer.getAmount().value)));
updateButtonDisableState();
} }
public void onShowPayFundsScreen() { public void onShowPayFundsScreen() {