mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add handlers for remove offer
This commit is contained in:
parent
3b35774b4b
commit
9e54279dd8
@ -21,6 +21,8 @@ import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.task.FaultHandler;
|
||||
import io.bitsquare.util.task.ResultHandler;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@ -33,7 +35,11 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.MapChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class OffersDataModel implements Activatable, DataModel {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffersDataModel.class);
|
||||
|
||||
private final TradeManager tradeManager;
|
||||
private final User user;
|
||||
@ -71,8 +77,8 @@ class OffersDataModel implements Activatable, DataModel {
|
||||
tradeManager.getOffers().removeListener(offerMapChangeListener);
|
||||
}
|
||||
|
||||
void removeOffer(OfferListItem item) {
|
||||
tradeManager.requestRemoveOffer(item.getOffer());
|
||||
void removeOffer(Offer offer, ResultHandler resultHandler, FaultHandler faultHandler) {
|
||||
tradeManager.requestRemoveOffer(offer, resultHandler, faultHandler);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.bitsquare.gui.main.portfolio.offer;
|
||||
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
@ -26,7 +27,11 @@ import viewfx.model.support.ActivatableWithDataModel;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class OffersViewModel extends ActivatableWithDataModel<OffersDataModel> implements ViewModel {
|
||||
private static final Logger log = LoggerFactory.getLogger(OffersViewModel.class);
|
||||
|
||||
private final BSFormatter formatter;
|
||||
|
||||
@ -40,10 +45,17 @@ class OffersViewModel extends ActivatableWithDataModel<OffersDataModel> implemen
|
||||
|
||||
|
||||
void removeOffer(OfferListItem item) {
|
||||
dataModel.removeOffer(item);
|
||||
dataModel.removeOffer(item.getOffer(),
|
||||
() -> {
|
||||
// visual feedback?
|
||||
log.debug("Remove offer was successful");
|
||||
},
|
||||
(message, throwable) -> {
|
||||
log.error(message);
|
||||
Popups.openWarningPopup("Remove offer failed", message);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public ObservableList<OfferListItem> getList() {
|
||||
return dataModel.getList();
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class OfferBookViewModel extends ActivatableWithDataModel<OfferBookDataModel> im
|
||||
dataModel.removeOffer(offer,
|
||||
() -> {
|
||||
// visual feedback?
|
||||
log.debug("remove was successful");
|
||||
log.debug("Remove offer was successful");
|
||||
},
|
||||
(message, throwable) -> {
|
||||
log.error(message);
|
||||
|
@ -256,7 +256,9 @@ public class TradeManager {
|
||||
public void onOfferAccepted(Offer offer) {
|
||||
trade.setState(Trade.State.OFFERER_ACCEPTED);
|
||||
persistPendingTrades();
|
||||
requestRemoveOffer(offer);
|
||||
requestRemoveOffer(offer,
|
||||
() -> log.debug("remove was successful"),
|
||||
(message, throwable) -> log.error(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user