diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java index afa84d5857..53df033ed1 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferView.java @@ -703,7 +703,15 @@ public abstract class MutableOfferView> 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) -> { diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/PortfolioView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/PortfolioView.java index 9af43f06a5..acfaf6bd94 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/PortfolioView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/PortfolioView.java @@ -191,6 +191,9 @@ public class PortfolioView extends ActivatableView { } 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; diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersDataModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersDataModel.java index 14dccd6ba4..c1f255d96d 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersDataModel.java @@ -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())); diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java index f0b1f1fc28..d3f2d7876d 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/openoffer/OpenOffersView.java @@ -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 widthListener; - private Map offerStateSubscriptions = new HashMap(); + private Map> offerStateChangeListeners = new HashMap>(); @Inject public OpenOffersView(OpenOffersViewModel model, Navigation navigation, OfferDetailsWindow offerDetailsWindow) { @@ -702,11 +700,16 @@ public class OpenOffersView extends ActivatableViewAndModel { - refresh(); - })); + + // refresh on state change + if (offerStateChangeListeners.containsKey(openOffer.getId())) { + openOffer.stateProperty().removeListener(offerStateChangeListeners.get(openOffer.getId())); + offerStateChangeListeners.remove(openOffer.getId()); } + ChangeListener 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;