mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Add missing filtering on lists - reusable code for contract filtering
This commit is contained in:
parent
2c920b47d6
commit
135541f28d
4 changed files with 28 additions and 50 deletions
|
@ -27,6 +27,7 @@ import bisq.desktop.components.InputTextField;
|
|||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.filtering.FilteringUtils;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
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)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
return FilteringUtils.match(trade.getContract(), filterString);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
|||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.main.portfolio.presentation.PortfolioUtil;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.filtering.FilteringUtils;
|
||||
|
||||
import bisq.core.alert.PrivateNotificationManager;
|
||||
import bisq.core.locale.Res;
|
||||
|
@ -449,22 +450,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
|
|||
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
return FilteringUtils.match(trade.getContract(), filterString);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import bisq.desktop.main.overlays.popups.Popup;
|
|||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.filtering.FilteringUtils;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.offer.Offer;
|
||||
|
@ -283,23 +284,7 @@ public class FailedTradesView extends ActivatableViewAndModel<VBox, FailedTrades
|
|||
if (trade.getPayoutTxId() != null && trade.getPayoutTxId().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
return FilteringUtils.match(trade.getContract(), filterString);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue