mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Refactor: rename getTradableList to getTradesAsObservableList
This commit is contained in:
parent
a5f4cb8e85
commit
6af9cb3dfe
@ -762,7 +762,7 @@ public class BisqSetup {
|
||||
}, 1);
|
||||
});
|
||||
|
||||
tradeManager.getTradableList().stream()
|
||||
tradeManager.getTradesAsObservableList().stream()
|
||||
.filter(trade -> trade.getOffer() != null)
|
||||
.forEach(trade -> {
|
||||
String details = null;
|
||||
|
@ -80,7 +80,7 @@ public class Balances {
|
||||
|
||||
public void onAllServicesInitialized() {
|
||||
openOfferManager.getObservableList().addListener((ListChangeListener<OpenOffer>) c -> updateBalance());
|
||||
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) change -> updateBalance());
|
||||
tradeManager.getTradesAsObservableList().addListener((ListChangeListener<Trade>) change -> updateBalance());
|
||||
refundManager.getDisputesAsObservableList().addListener((ListChangeListener<Dispute>) c -> updateBalance());
|
||||
btcWalletService.addBalanceListener(new BalanceListener() {
|
||||
@Override
|
||||
|
@ -53,13 +53,13 @@ public class TradeEvents {
|
||||
}
|
||||
|
||||
public void onAllServicesInitialized() {
|
||||
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) c -> {
|
||||
tradeManager.getTradesAsObservableList().addListener((ListChangeListener<Trade>) c -> {
|
||||
c.next();
|
||||
if (c.wasAdded()) {
|
||||
c.getAddedSubList().forEach(this::setTradePhaseListener);
|
||||
}
|
||||
});
|
||||
tradeManager.getTradableList().forEach(this::setTradePhaseListener);
|
||||
tradeManager.getTradesAsObservableList().forEach(this::setTradePhaseListener);
|
||||
}
|
||||
|
||||
private void setTradePhaseListener(Trade trade) {
|
||||
|
@ -102,7 +102,7 @@ public class TraderChatManager extends SupportManager {
|
||||
|
||||
@Override
|
||||
public List<ChatMessage> getAllChatMessages() {
|
||||
return tradeManager.getTradableList().stream()
|
||||
return tradeManager.getTradesAsObservableList().stream()
|
||||
.flatMap(trade -> trade.getChatMessages().stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
}
|
||||
});
|
||||
|
||||
getTradableList().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
|
||||
getTradesAsObservableList().addListener((ListChangeListener<Trade>) change -> onTradesChanged());
|
||||
onTradesChanged();
|
||||
|
||||
getAddressEntriesForAvailableBalanceStream()
|
||||
@ -301,7 +301,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
}
|
||||
|
||||
private void onTradesChanged() {
|
||||
this.numPendingTrades.set(getTradableList().size());
|
||||
this.numPendingTrades.set(getTradesAsObservableList().size());
|
||||
}
|
||||
|
||||
private void handlePayDepositRequest(InputsForDepositTxRequest inputsForDepositTxRequest, NodeAddress peer) {
|
||||
@ -675,7 +675,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public ObservableList<Trade> getTradableList() {
|
||||
public ObservableList<Trade> getTradesAsObservableList() {
|
||||
return tradableList.getList();
|
||||
}
|
||||
|
||||
@ -709,7 +709,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
}
|
||||
|
||||
public Stream<Trade> getTradesStreamWithFundsLockedIn() {
|
||||
return getTradableList().stream()
|
||||
return getTradesAsObservableList().stream()
|
||||
.filter(Trade::isFundsLockedIn);
|
||||
}
|
||||
|
||||
@ -766,7 +766,7 @@ public class TradeManager implements PersistedDataHost {
|
||||
}
|
||||
|
||||
private void updateTradePeriodState() {
|
||||
getTradableList().forEach(trade -> {
|
||||
getTradesAsObservableList().forEach(trade -> {
|
||||
if (!trade.isPayoutPublished()) {
|
||||
Date maxTradePeriodDate = trade.getMaxTradePeriodDate();
|
||||
Date halfTradePeriodDate = trade.getHalfTradePeriodDate();
|
||||
|
@ -181,7 +181,7 @@ public class XmrTxProofService implements AssetTxProofService {
|
||||
});
|
||||
|
||||
// We listen on new trades
|
||||
ObservableList<Trade> tradableList = tradeManager.getTradableList();
|
||||
ObservableList<Trade> tradableList = tradeManager.getTradesAsObservableList();
|
||||
tradableList.addListener((ListChangeListener<Trade>) c -> {
|
||||
c.next();
|
||||
if (c.wasAdded()) {
|
||||
@ -238,7 +238,7 @@ public class XmrTxProofService implements AssetTxProofService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wasTxKeyReUsed(trade, tradeManager.getTradableList())) {
|
||||
if (wasTxKeyReUsed(trade, tradeManager.getTradesAsObservableList())) {
|
||||
trade.setAssetTxProofResult(AssetTxProofResult.INVALID_DATA
|
||||
.details(Res.get("portfolio.pending.autoConf.state.xmr.txKeyReused")));
|
||||
return;
|
||||
|
@ -219,7 +219,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
|
||||
if (newValue) {
|
||||
tradeManager.applyTradePeriodState();
|
||||
|
||||
tradeManager.getTradableList().forEach(trade -> {
|
||||
tradeManager.getTradesAsObservableList().forEach(trade -> {
|
||||
Date maxTradePeriodDate = trade.getMaxTradePeriodDate();
|
||||
String key;
|
||||
switch (trade.getTradePeriodState()) {
|
||||
|
@ -130,7 +130,7 @@ class AltCoinAccountsDataModel extends ActivatableDataModel {
|
||||
.filter(o -> o.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()))
|
||||
.findAny()
|
||||
.isPresent();
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getTradableList().stream()
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getTradesAsObservableList().stream()
|
||||
.filter(t -> t.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()) ||
|
||||
paymentAccount.getId().equals(t.getTakerPaymentAccountId()))
|
||||
.findAny()
|
||||
|
@ -136,7 +136,7 @@ class FiatAccountsDataModel extends ActivatableDataModel {
|
||||
public boolean onDeleteAccount(PaymentAccount paymentAccount) {
|
||||
boolean isPaymentAccountUsed = openOfferManager.getObservableList().stream()
|
||||
.anyMatch(o -> o.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()));
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getTradableList().stream()
|
||||
isPaymentAccountUsed = isPaymentAccountUsed || tradeManager.getTradesAsObservableList().stream()
|
||||
.anyMatch(t -> t.getOffer().getMakerPaymentAccountId().equals(paymentAccount.getId()) ||
|
||||
paymentAccount.getId().equals(t.getTakerPaymentAccountId()));
|
||||
if (!isPaymentAccountUsed)
|
||||
|
@ -143,7 +143,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
|
||||
@Override
|
||||
protected void activate() {
|
||||
openOfferManager.getObservableList().addListener(openOfferListChangeListener);
|
||||
tradeManager.getTradableList().addListener(tradeListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().addListener(tradeListChangeListener);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
updateList();
|
||||
@ -154,7 +154,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
openOfferManager.getObservableList().removeListener(openOfferListChangeListener);
|
||||
tradeManager.getTradableList().removeListener(tradeListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().removeListener(tradeListChangeListener);
|
||||
sortedList.comparatorProperty().unbind();
|
||||
observableList.forEach(LockedListItem::cleanup);
|
||||
btcWalletService.removeBalanceListener(balanceListener);
|
||||
|
@ -143,7 +143,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
|
||||
@Override
|
||||
protected void activate() {
|
||||
openOfferManager.getObservableList().addListener(openOfferListChangeListener);
|
||||
tradeManager.getTradableList().addListener(tradeListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().addListener(tradeListChangeListener);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
updateList();
|
||||
@ -154,7 +154,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
openOfferManager.getObservableList().removeListener(openOfferListChangeListener);
|
||||
tradeManager.getTradableList().removeListener(tradeListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().removeListener(tradeListChangeListener);
|
||||
sortedList.comparatorProperty().unbind();
|
||||
observableList.forEach(ReservedListItem::cleanup);
|
||||
btcWalletService.removeBalanceListener(balanceListener);
|
||||
|
@ -51,7 +51,7 @@ public class TradableRepository {
|
||||
Set<Tradable> getAll() {
|
||||
return ImmutableSet.<Tradable>builder()
|
||||
.addAll(openOfferManager.getObservableList())
|
||||
.addAll(tradeManager.getTradableList())
|
||||
.addAll(tradeManager.getTradesAsObservableList())
|
||||
.addAll(closedTradableManager.getClosedTradables())
|
||||
.addAll(failedTradesManager.getFailedTrades())
|
||||
.build();
|
||||
|
@ -392,7 +392,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
||||
log.error("onWithdraw transaction is null");
|
||||
}
|
||||
|
||||
List<Trade> trades = new ArrayList<>(tradeManager.getTradableList());
|
||||
List<Trade> trades = new ArrayList<>(tradeManager.getTradesAsObservableList());
|
||||
trades.stream()
|
||||
.filter(Trade::isPayoutPublished)
|
||||
.forEach(trade -> walletService.getAddressEntry(trade.getId(), AddressEntry.Context.TRADE_PAYOUT)
|
||||
|
@ -109,7 +109,7 @@ public class NotificationCenter {
|
||||
}
|
||||
|
||||
public void onAllServicesAndViewsInitialized() {
|
||||
tradeManager.getTradableList().addListener((ListChangeListener<Trade>) change -> {
|
||||
tradeManager.getTradesAsObservableList().addListener((ListChangeListener<Trade>) change -> {
|
||||
change.next();
|
||||
if (change.wasRemoved()) {
|
||||
change.getRemoved().stream().forEach(trade -> {
|
||||
@ -147,7 +147,7 @@ public class NotificationCenter {
|
||||
}
|
||||
});
|
||||
|
||||
tradeManager.getTradableList().stream()
|
||||
tradeManager.getTradesAsObservableList().stream()
|
||||
.forEach(trade -> {
|
||||
String tradeId = trade.getId();
|
||||
Subscription disputeStateSubscription = EasyBind.subscribe(trade.disputeStateProperty(),
|
||||
|
@ -159,7 +159,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
tradeManager.getTradableList().addListener(tradesListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().addListener(tradesListChangeListener);
|
||||
onListChanged();
|
||||
if (selectedItemProperty.get() != null)
|
||||
notificationCenter.setSelectedTradeId(selectedItemProperty.get().getTrade().getId());
|
||||
@ -169,7 +169,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
tradeManager.getTradableList().removeListener(tradesListChangeListener);
|
||||
tradeManager.getTradesAsObservableList().removeListener(tradesListChangeListener);
|
||||
notificationCenter.setSelectedTradeId(null);
|
||||
activated = false;
|
||||
}
|
||||
@ -373,7 +373,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
|
||||
|
||||
private void onListChanged() {
|
||||
list.clear();
|
||||
list.addAll(tradeManager.getTradableList().stream().map(PendingTradesListItem::new).collect(Collectors.toList()));
|
||||
list.addAll(tradeManager.getTradesAsObservableList().stream().map(PendingTradesListItem::new).collect(Collectors.toList()));
|
||||
|
||||
// we sort by date, earliest first
|
||||
list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate()));
|
||||
|
Loading…
Reference in New Issue
Block a user