Skip to content

Commit

Permalink
Merge pull request #4651 from ripcurlx/keep-offer-when-canceling
Browse files Browse the repository at this point in the history
Only remove offer locally when necessary
  • Loading branch information
sqrrm authored Oct 15, 2020
2 parents b7c6c42 + c08a9bd commit 101c172
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -893,7 +897,7 @@ private void addButtons() {
cancelButton1.setDefaultButton(false);
cancelButton1.setOnAction(e -> {
model.dataModel.swapTradeToSavings();
close();
close(false);
});
}

Expand Down Expand Up @@ -1040,7 +1044,7 @@ private void addFundingGroup() {
})
.show();
} else {
close();
close(false);
model.dataModel.swapTradeToSavings();
}
});
Expand Down

0 comments on commit 101c172

Please sign in to comment.