Add missing filtering on lists - reusable code for contract filtering

This commit is contained in:
xyzmaker123 2022-01-21 16:38:49 +01:00
parent 2c920b47d6
commit 135541f28d
No known key found for this signature in database
GPG key ID: 47689699B7B0AAFC
4 changed files with 28 additions and 50 deletions

View file

@ -27,6 +27,7 @@ import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow; import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow; import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.util.GUIUtil; import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.filtering.FilteringUtils;
import bisq.core.btc.listeners.BalanceListener; import bisq.core.btc.listeners.BalanceListener;
import bisq.core.btc.model.AddressEntry; import bisq.core.btc.model.AddressEntry;
@ -269,23 +270,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) { if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true; return true;
} }
return FilteringUtils.match(trade.getContract(), filterString);
Contract contract = trade.getContract();
boolean isBuyerOnion = false;
boolean isSellerOnion = false;
boolean matchesBuyersPaymentAccountData = false;
boolean matchesSellersPaymentAccountData = false;
if (contract != null) {
isBuyerOnion = contract.getBuyerNodeAddress().getFullAddress().contains(filterString);
isSellerOnion = contract.getSellerNodeAddress().getFullAddress().contains(filterString);
matchesBuyersPaymentAccountData = contract.getBuyerPaymentAccountPayload() != null &&
contract.getBuyerPaymentAccountPayload().getPaymentDetails().contains(filterString);
matchesSellersPaymentAccountData = contract.getSellerPaymentAccountPayload() != null &&
contract.getSellerPaymentAccountPayload().getPaymentDetails().contains(filterString);
}
return isBuyerOnion || isSellerOnion ||
matchesBuyersPaymentAccountData || matchesSellersPaymentAccountData;
} else { } else {
return false; return false;
} }

View file

@ -33,6 +33,7 @@ import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow; import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.main.portfolio.presentation.PortfolioUtil; import bisq.desktop.main.portfolio.presentation.PortfolioUtil;
import bisq.desktop.util.GUIUtil; import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.filtering.FilteringUtils;
import bisq.core.alert.PrivateNotificationManager; import bisq.core.alert.PrivateNotificationManager;
import bisq.core.locale.Res; import bisq.core.locale.Res;
@ -449,22 +450,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) { if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true; return true;
} }
return FilteringUtils.match(trade.getContract(), filterString);
Contract contract = trade.getContract();
boolean isBuyerOnion = false;
boolean isSellerOnion = false;
boolean matchesBuyersPaymentAccountData = false;
boolean matchesSellersPaymentAccountData = false;
if (contract != null) {
isBuyerOnion = contract.getBuyerNodeAddress().getFullAddress().contains(filterString);
isSellerOnion = contract.getSellerNodeAddress().getFullAddress().contains(filterString);
matchesBuyersPaymentAccountData = contract.getBuyerPaymentAccountPayload() != null &&
contract.getBuyerPaymentAccountPayload().getPaymentDetails().contains(filterString);
matchesSellersPaymentAccountData = contract.getSellerPaymentAccountPayload() != null &&
contract.getSellerPaymentAccountPayload().getPaymentDetails().contains(filterString);
}
return isBuyerOnion || isSellerOnion ||
matchesBuyersPaymentAccountData || matchesSellersPaymentAccountData;
} else { } else {
return false; return false;
} }

View file

@ -27,6 +27,7 @@ import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow; import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.util.FormBuilder; import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil; import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.filtering.FilteringUtils;
import bisq.core.locale.Res; import bisq.core.locale.Res;
import bisq.core.offer.Offer; import bisq.core.offer.Offer;
@ -283,23 +284,7 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) { if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
return true; return true;
} }
return FilteringUtils.match(trade.getContract(), filterString);
Contract contract = trade.getContract();
boolean isBuyerOnion = false;
boolean isSellerOnion = false;
boolean matchesBuyersPaymentAccountData = false;
boolean matchesSellersPaymentAccountData = false;
if (contract != null) {
isBuyerOnion = contract.getBuyerNodeAddress().getFullAddress().contains(filterString);
isSellerOnion = contract.getSellerNodeAddress().getFullAddress().contains(filterString);
matchesBuyersPaymentAccountData = contract.getBuyerPaymentAccountPayload() != null &&
contract.getBuyerPaymentAccountPayload().getPaymentDetails().contains(filterString);
matchesSellersPaymentAccountData = contract.getSellerPaymentAccountPayload() != null &&
contract.getSellerPaymentAccountPayload().getPaymentDetails().contains(filterString);
}
return isBuyerOnion || isSellerOnion ||
matchesBuyersPaymentAccountData || matchesSellersPaymentAccountData;
}); });
} }

View file

@ -0,0 +1,22 @@
package bisq.desktop.util.filtering;
import bisq.core.trade.model.bisq_v1.Contract;
public class FilteringUtils {
public static boolean match(Contract contract, String filterString) {
boolean isBuyerOnion = false;
boolean isSellerOnion = false;
boolean matchesBuyersPaymentAccountData = false;
boolean matchesSellersPaymentAccountData = false;
if (contract != null) {
isBuyerOnion = contract.getBuyerNodeAddress().getFullAddress().contains(filterString);
isSellerOnion = contract.getSellerNodeAddress().getFullAddress().contains(filterString);
matchesBuyersPaymentAccountData = contract.getBuyerPaymentAccountPayload() != null &&
contract.getBuyerPaymentAccountPayload().getPaymentDetails().contains(filterString);
matchesSellersPaymentAccountData = contract.getSellerPaymentAccountPayload() != null &&
contract.getSellerPaymentAccountPayload().getPaymentDetails().contains(filterString);
}
return isBuyerOnion || isSellerOnion ||
matchesBuyersPaymentAccountData || matchesSellersPaymentAccountData;
}
}