mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-02-22 23:49:54 -05:00
prevent trade mixup in ui by synchronizing trade and state events
This commit is contained in:
parent
6b105f80cf
commit
6e901c9852
@ -19,7 +19,6 @@ package haveno.desktop.main.portfolio.pendingtrades;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import haveno.common.ClockWatcher;
|
import haveno.common.ClockWatcher;
|
||||||
import haveno.common.UserThread;
|
|
||||||
import haveno.common.app.DevEnv;
|
import haveno.common.app.DevEnv;
|
||||||
import haveno.core.account.witness.AccountAgeWitnessService;
|
import haveno.core.account.witness.AccountAgeWitnessService;
|
||||||
import haveno.core.network.MessageState;
|
import haveno.core.network.MessageState;
|
||||||
@ -148,6 +147,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void deactivate() {
|
protected void deactivate() {
|
||||||
|
synchronized (this) {
|
||||||
if (tradeStateSubscription != null) {
|
if (tradeStateSubscription != null) {
|
||||||
tradeStateSubscription.unsubscribe();
|
tradeStateSubscription.unsubscribe();
|
||||||
tradeStateSubscription = null;
|
tradeStateSubscription = null;
|
||||||
@ -163,9 +163,11 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||||||
messageStateSubscription = null;
|
messageStateSubscription = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't set own listener as we need to control the order of the calls
|
// Don't set own listener as we need to control the order of the calls
|
||||||
public void onSelectedItemChanged(PendingTradesListItem selectedItem) {
|
public void onSelectedItemChanged(PendingTradesListItem selectedItem) {
|
||||||
|
synchronized (this) {
|
||||||
if (tradeStateSubscription != null) {
|
if (tradeStateSubscription != null) {
|
||||||
tradeStateSubscription.unsubscribe();
|
tradeStateSubscription.unsubscribe();
|
||||||
sellerState.set(SellerState.UNDEFINED);
|
sellerState.set(SellerState.UNDEFINED);
|
||||||
@ -186,17 +188,18 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||||||
if (selectedItem != null) {
|
if (selectedItem != null) {
|
||||||
this.trade = selectedItem.getTrade();
|
this.trade = selectedItem.getTrade();
|
||||||
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), state -> {
|
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), state -> {
|
||||||
UserThread.execute(() -> onTradeStateChanged(state));
|
onTradeStateChanged(state);
|
||||||
});
|
});
|
||||||
payoutStateSubscription = EasyBind.subscribe(trade.payoutStateProperty(), state -> {
|
payoutStateSubscription = EasyBind.subscribe(trade.payoutStateProperty(), state -> {
|
||||||
UserThread.execute(() -> onPayoutStateChanged(state));
|
onPayoutStateChanged(state);
|
||||||
});
|
});
|
||||||
messageStateSubscription = EasyBind.subscribe(trade.getProcessModel().getPaymentSentMessageStateProperty(), this::onMessageStateChanged);
|
messageStateSubscription = EasyBind.subscribe(trade.getProcessModel().getPaymentSentMessageStateProperty(), this::onMessageStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessageStateProperty(MessageState messageState) {
|
public void setMessageStateProperty(MessageState messageState) {
|
||||||
|
|
||||||
// ARRIVED is set internally after ACKNOWLEDGED, otherwise warn if subsequent states received
|
// ARRIVED is set internally after ACKNOWLEDGED, otherwise warn if subsequent states received
|
||||||
if ((messageStateProperty.get() == MessageState.ACKNOWLEDGED && messageState != MessageState.ARRIVED) || messageStateProperty.get() == MessageState.ARRIVED) {
|
if ((messageStateProperty.get() == MessageState.ACKNOWLEDGED && messageState != MessageState.ARRIVED) || messageStateProperty.get() == MessageState.ARRIVED) {
|
||||||
log.warn("We have already an ACKNOWLEDGED/ARRIVED message received. " +
|
log.warn("We have already an ACKNOWLEDGED/ARRIVED message received. " +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user