Add missing filtering on lists - reusable code for Trade filtering

This commit is contained in:
xyzmaker123 2022-01-21 17:20:20 +01:00
parent 4cd744fb14
commit 1b571e9575
No known key found for this signature in database
GPG key ID: 47689699B7B0AAFC
4 changed files with 27 additions and 46 deletions

View file

@ -259,21 +259,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
return true;
}
Trade trade = item.getTrade();
if (trade != null) {
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getDepositTxId() != null && trade.getDepositTxId().contains(filterString)) {
return true;
}
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true;
}
return FilteringUtils.match(trade.getContract(), filterString);
} else {
return false;
}
return FilteringUtils.match(item.getTrade(), filterString);
});
}

View file

@ -420,26 +420,13 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
if (FilteringUtils.match(tradable.getOffer(), filterString)) {
return true;
}
if (tradable instanceof BsqSwapTrade && FilteringUtils.match((BsqSwapTrade) tradable, filterString)) {
return true;
}
if (tradable instanceof Trade) {
Trade trade = (Trade) tradable;
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getDepositTxId() != null && trade.getDepositTxId().contains(filterString)) {
return true;
}
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true;
}
return FilteringUtils.match(trade.getContract(), filterString);
} else {
return false;
if (tradable instanceof Trade && FilteringUtils.match((Trade) tradable, filterString)) {
return true;
}
return false;
});
}

View file

@ -266,19 +266,7 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
if (FilteringUtils.match(item.getTrade().getOffer(), filterString)) {
return true;
}
Trade trade = item.getTrade();
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getDepositTxId() != null && trade.getDepositTxId().contains(filterString)) {
return true;
}
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true;
}
return FilteringUtils.match(trade.getContract(), filterString);
return FilteringUtils.match(item.getTrade(), filterString);
});
}

View file

@ -2,10 +2,11 @@ package bisq.desktop.util.filtering;
import bisq.core.offer.Offer;
import bisq.core.trade.model.bisq_v1.Contract;
import bisq.core.trade.model.bisq_v1.Trade;
import bisq.core.trade.model.bsq_swap.BsqSwapTrade;
public class FilteringUtils {
public static boolean match(Contract contract, String filterString) {
private static boolean match(Contract contract, String filterString) {
boolean isBuyerOnion = false;
boolean isSellerOnion = false;
boolean matchesBuyersPaymentAccountData = false;
@ -44,4 +45,23 @@ public class FilteringUtils {
}
return false;
}
public static boolean match(Trade trade, String filterString) {
if (trade == null) {
return false;
}
if (trade.getTakerFeeTxId() != null && trade.getTakerFeeTxId().contains(filterString)) {
return true;
}
if (trade.getDepositTxId() != null && trade.getDepositTxId().contains(filterString)) {
return true;
}
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true;
}
if (match(trade.getContract(), filterString)) {
return true;
}
return false;
}
}