From c08a9bdac26b35c7182f40e85da4f4e103997d4a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 15 Oct 2020 09:53:01 +0200 Subject: [PATCH] Only remove offer locally when necessary --- .../main/offer/takeoffer/TakeOfferDataModel.java | 6 ++++-- .../desktop/main/offer/takeoffer/TakeOfferView.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java index 8e2c92fc536..95cff8bc867 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java @@ -267,14 +267,16 @@ void onTabSelected(boolean isSelected) { priceFeedService.setCurrencyCode(offer.getCurrencyCode()); } - public void onClose() { + public void onClose(boolean removeOffer) { // We do not wait until the offer got removed by a network remove message but remove it // directly from the offer book. The broadcast gets now bundled and has 2 sec. delay so the // removal from the network is a bit slower as it has been before. To avoid that the taker gets // confused to see the same offer still in the offerbook we remove it manually. This removal has // only local effect. Other trader might see the offer for a few seconds // still (but cannot take it). - offerBook.removeOffer(checkNotNull(offer), tradeManager); + if (removeOffer) { + offerBook.removeOffer(checkNotNull(offer), tradeManager); + } btcWalletService.resetAddressEntriesForOpenOffer(offer.getId()); } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java index 0ae302cb6d4..47316e0ace5 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java @@ -388,7 +388,7 @@ public void initWithData(Offer offer) { if (offer.getPrice() == null) new Popup().warning(Res.get("takeOffer.noPriceFeedAvailable")) - .onClose(this::close) + .onClose(() -> close(false)) .show(); } @@ -595,7 +595,11 @@ private void updateOfferElementsStyle() { /////////////////////////////////////////////////////////////////////////////////////////// private void close() { - model.dataModel.onClose(); + close(true); + } + + private void close(boolean removeOffer) { + model.dataModel.onClose(removeOffer); if (closeHandler != null) closeHandler.close(); } @@ -893,7 +897,7 @@ private void addButtons() { cancelButton1.setDefaultButton(false); cancelButton1.setOnAction(e -> { model.dataModel.swapTradeToSavings(); - close(); + close(false); }); } @@ -1040,7 +1044,7 @@ private void addFundingGroup() { }) .show(); } else { - close(); + close(false); model.dataModel.swapTradeToSavings(); } });