update offer state on same thread to fix blocking

This commit is contained in:
woodser 2024-04-06 17:39:21 -04:00
parent 6fea58c197
commit 59fbd805a5
4 changed files with 76 additions and 70 deletions

View File

@ -265,7 +265,7 @@ public class Offer implements NetworkPayload, PersistablePayload {
///////////////////////////////////////////////////////////////////////////////////////////
public void setState(Offer.State state) {
UserThread.await(() -> stateProperty().set(state));
stateProperty.set(state);
}
public ObjectProperty<Offer.State> stateProperty() {

View File

@ -200,6 +200,7 @@ public class MarketView extends ActivatableView<TabPane, Void> {
}
private String getAllOffersWithReferralId() {
synchronized (offerBook.getOfferBookListItems()) {
List<String> list = offerBook.getOfferBookListItems().stream()
.map(OfferBookListItem::getOffer)
.filter(offer -> offer.getExtraDataMap() != null)
@ -219,3 +220,4 @@ public class MarketView extends ActivatableView<TabPane, Void> {
return Joiner.on("\n\n").join(list);
}
}
}

View File

@ -147,6 +147,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
private void fillTradeCurrencies() {
// Don't use a set as we need all entries
synchronized (offerBookListItems) {
List<TradeCurrency> tradeCurrencyList = offerBookListItems.stream()
.map(e -> {
String currencyCode = e.getOffer().getCurrencyCode();
@ -158,6 +159,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
currencyListItems.updateWithCurrencies(tradeCurrencyList, null);
}
}
@Override
protected void activate() {

View File

@ -350,6 +350,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
///////////////////////////////////////////////////////////////////////////////////////////
private void applyOfferState(Offer.State state) {
UserThread.execute(() -> {
offerWarning.set(null);
// We have 2 situations handled here:
@ -394,6 +395,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
updateSpinnerInfo();
updateButtonDisableState();
});
}
private void applyTradeErrorMessage(@Nullable String errorMessage) {