Skip to content

Commit

Permalink
Clean up init data when taking offer
Browse files Browse the repository at this point in the history
  • Loading branch information
axpoems committed Jan 24, 2025
1 parent d187a8e commit acd9758
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package bisq.desktop.main.content.bisq_easy.components.amount_selection;

import bisq.common.currency.FiatCurrencyRepository;
import bisq.common.currency.Market;
import bisq.common.currency.TradeCurrency;
import bisq.common.monetary.Fiat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package bisq.desktop.main.content.bisq_easy.take_offer;

import bisq.bisq_easy.NavigationTarget;
import bisq.common.monetary.Monetary;
import bisq.desktop.ServiceProvider;
import bisq.desktop.common.utils.KeyHandlerUtil;
import bisq.desktop.common.view.Controller;
Expand Down Expand Up @@ -54,11 +53,9 @@ public class TakeOfferController extends NavigationController implements InitWit
@ToString
public static class InitData {
private final BisqEasyOffer bisqEasyOffer;
private final Optional<Monetary> reputationBasedQuoteSideAmount;

public InitData(BisqEasyOffer bisqEasyOffer, Optional<Monetary> reputationBasedQuoteSideAmount) {
public InitData(BisqEasyOffer bisqEasyOffer) {
this.bisqEasyOffer = bisqEasyOffer;
this.reputationBasedQuoteSideAmount = reputationBasedQuoteSideAmount;
}
}

Expand Down Expand Up @@ -94,7 +91,7 @@ public boolean useCaching() {
@Override
public void initWithData(InitData initData) {
BisqEasyOffer bisqEasyOffer = initData.getBisqEasyOffer();
takeOfferAmountController.init(bisqEasyOffer, initData.getReputationBasedQuoteSideAmount());
takeOfferAmountController.init(bisqEasyOffer);
takeOfferPaymentController.init(bisqEasyOffer);
takeOfferReviewController.init(bisqEasyOffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public TakeOfferAmountController(ServiceProvider serviceProvider,
view = new TakeOfferAmountView(model, this, amountSelectionController.getView().getRoot());
}

public void init(BisqEasyOffer bisqEasyOffer, Optional<Monetary> optionalReputationBasedQuoteSideAmount) {
public void init(BisqEasyOffer bisqEasyOffer) {
model.setBisqEasyOffer(bisqEasyOffer);

Direction takersDirection = bisqEasyOffer.getTakersDirection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.content.chat.message_container.list;

import bisq.bisq_easy.BisqEasyTradeAmountLimits;
Expand All @@ -21,7 +38,6 @@
import bisq.chat.reactions.*;
import bisq.chat.two_party.TwoPartyPrivateChatChannel;
import bisq.chat.two_party.TwoPartyPrivateChatMessage;
import bisq.common.monetary.Monetary;
import bisq.common.observable.Pin;
import bisq.common.observable.collection.CollectionObserver;
import bisq.desktop.ServiceProvider;
Expand All @@ -38,7 +54,6 @@
import bisq.network.identity.NetworkId;
import bisq.network.p2p.services.confidential.resend.ResendMessageService;
import bisq.offer.amount.OfferAmountFormatter;
import bisq.offer.amount.OfferAmountUtil;
import bisq.offer.amount.spec.RangeAmountSpec;
import bisq.offer.bisq_easy.BisqEasyOffer;
import bisq.settings.SettingsService;
Expand Down Expand Up @@ -341,14 +356,7 @@ public void onTakeOffer(BisqEasyOfferbookMessage bisqEasyOfferbookMessage) {
isAmountRangeOffer ? minFiatAmount : maxFiatAmount))
.show();
} else {
Optional<Monetary> reputationBasedQuoteSideAmount = BisqEasyTradeAmountLimits.getReputationBasedQuoteSideAmount(marketPriceService, bisqEasyOffer.getMarket(), sellersScore);
Monetary offersMaxAmount = OfferAmountUtil.findQuoteSideMaxOrFixedAmount(marketPriceService, bisqEasyOffer).orElseThrow();
if (reputationBasedQuoteSideAmount.isPresent() && offersMaxAmount.isGreaterThan(reputationBasedQuoteSideAmount.get())) {
Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer, reputationBasedQuoteSideAmount));
} else {
Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer, Optional.empty()));
}

Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer));
}
} else {
// I am as taker the seller. We check if my reputation permits to take the offer
Expand All @@ -365,13 +373,7 @@ public void onTakeOffer(BisqEasyOfferbookMessage bisqEasyOfferbookMessage) {
isAmountRangeOffer ? minFiatAmount : maxFiatAmount))
.show();
} else {
Optional<Monetary> reputationBasedQuoteSideAmount = BisqEasyTradeAmountLimits.getReputationBasedQuoteSideAmount(marketPriceService, bisqEasyOffer.getMarket(), sellersScore);
Monetary offersMaxAmount = OfferAmountUtil.findQuoteSideMaxOrFixedAmount(marketPriceService, bisqEasyOffer).orElseThrow();
if (reputationBasedQuoteSideAmount.isPresent() && offersMaxAmount.isGreaterThan(reputationBasedQuoteSideAmount.get())) {
Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer, reputationBasedQuoteSideAmount));
} else {
Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer, Optional.empty()));
}
Navigation.navigateTo(NavigationTarget.TAKE_OFFER, new TakeOfferController.InitData(bisqEasyOffer));
}
}
} else {
Expand Down

0 comments on commit acd9758

Please sign in to comment.