mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
fixes to editing offers #1011
This commit is contained in:
parent
57948b36fd
commit
438e8d41cb
@ -703,7 +703,15 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel<?>> exten
|
||||
marketBasedPriceTextField.clear();
|
||||
volumeTextField.clear();
|
||||
triggerPriceInputTextField.clear();
|
||||
initWithData(model.dataModel.direction, model.getTradeCurrency(), offerActionHandler);
|
||||
if (!CurrencyUtil.isTraditionalCurrency(newValue)) {
|
||||
if (model.isShownAsBuyOffer()) {
|
||||
placeOfferButton.updateText(Res.get("createOffer.placeOfferButtonCrypto", Res.get("shared.buy"),
|
||||
model.getTradeCurrency().getCode()));
|
||||
} else {
|
||||
placeOfferButton.updateText(Res.get("createOffer.placeOfferButtonCrypto", Res.get("shared.sell"),
|
||||
model.getTradeCurrency().getCode()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
placeOfferCompletedListener = (o, oldValue, newValue) -> {
|
||||
|
@ -191,6 +191,9 @@ public class PortfolioView extends ActivatableView<TabPane, Void> {
|
||||
} else if (view instanceof FailedTradesView) {
|
||||
currentTab = failedTradesTab;
|
||||
} else if (view instanceof EditOfferView) {
|
||||
if (data instanceof OpenOffer) {
|
||||
openOffer = (OpenOffer) data;
|
||||
}
|
||||
if (openOffer != null) {
|
||||
if (editOfferView == null) {
|
||||
editOfferView = (EditOfferView) view;
|
||||
|
@ -18,6 +18,7 @@
|
||||
package haveno.desktop.main.portfolio.openoffer;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import haveno.common.UserThread;
|
||||
import haveno.common.handlers.ErrorMessageHandler;
|
||||
import haveno.common.handlers.ResultHandler;
|
||||
import haveno.core.offer.Offer;
|
||||
@ -46,9 +47,8 @@ class OpenOffersDataModel extends ActivatableDataModel {
|
||||
public OpenOffersDataModel(OpenOfferManager openOfferManager, PriceFeedService priceFeedService) {
|
||||
this.openOfferManager = openOfferManager;
|
||||
this.priceFeedService = priceFeedService;
|
||||
|
||||
tradesListChangeListener = change -> applyList();
|
||||
currenciesUpdateFlagPropertyListener = (observable, oldValue, newValue) -> applyList();
|
||||
tradesListChangeListener = change -> UserThread.execute(() -> applyList());
|
||||
currenciesUpdateFlagPropertyListener = (observable, oldValue, newValue) -> UserThread.execute(() -> applyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,7 +85,7 @@ class OpenOffersDataModel extends ActivatableDataModel {
|
||||
return openOfferManager.isMyOffer(offer) ? offer.getDirection() : offer.getMirroredDirection();
|
||||
}
|
||||
|
||||
private void applyList() {
|
||||
private synchronized void applyList() {
|
||||
list.clear();
|
||||
|
||||
list.addAll(openOfferManager.getOpenOffers().stream().map(OpenOfferListItem::new).collect(Collectors.toList()));
|
||||
|
@ -75,8 +75,6 @@ import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@FxmlView
|
||||
@ -113,7 +111,7 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
|
||||
private PortfolioView.OpenOfferActionHandler openOfferActionHandler;
|
||||
private ChangeListener<Number> widthListener;
|
||||
|
||||
private Map<String, Subscription> offerStateSubscriptions = new HashMap<String, Subscription>();
|
||||
private Map<String, ChangeListener<OpenOffer.State>> offerStateChangeListeners = new HashMap<String, ChangeListener<OpenOffer.State>>();
|
||||
|
||||
@Inject
|
||||
public OpenOffersView(OpenOffersViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow) {
|
||||
@ -702,11 +700,16 @@ public class OpenOffersView extends ActivatableViewAndModel<VBox, OpenOffersView
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
OpenOffer openOffer = item.getOpenOffer();
|
||||
if (!offerStateSubscriptions.containsKey(openOffer.getId())) {
|
||||
offerStateSubscriptions.put(openOffer.getId(), EasyBind.subscribe(openOffer.stateProperty(), state -> {
|
||||
refresh();
|
||||
}));
|
||||
|
||||
// refresh on state change
|
||||
if (offerStateChangeListeners.containsKey(openOffer.getId())) {
|
||||
openOffer.stateProperty().removeListener(offerStateChangeListeners.get(openOffer.getId()));
|
||||
offerStateChangeListeners.remove(openOffer.getId());
|
||||
}
|
||||
ChangeListener<OpenOffer.State> listener = (observable, oldValue, newValue) -> { if (oldValue != newValue) refresh(); };
|
||||
offerStateChangeListeners.put(openOffer.getId(), listener);
|
||||
openOffer.stateProperty().addListener(listener);
|
||||
|
||||
if (openOffer.getState() == OpenOffer.State.SCHEDULED) {
|
||||
setGraphic(new AutoTooltipLabel(Res.get("shared.pending")));
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user