fix payment sent message state property after improper shut down

This commit is contained in:
woodser 2024-01-11 10:22:38 -05:00
parent db155283be
commit 2b9d0ef5a6
4 changed files with 34 additions and 11 deletions

View file

@ -191,14 +191,12 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
});
messageStateSubscription = EasyBind.subscribe(trade.getProcessModel().getPaymentSentMessageStateProperty(), this::onMessageStateChanged);
}
}
}
public void setMessageStateProperty(MessageState messageState) {
// ARRIVED is set internally after ACKNOWLEDGED, otherwise warn if subsequent states received
if ((messageStateProperty.get() == MessageState.ACKNOWLEDGED && messageState != MessageState.ARRIVED) || messageStateProperty.get() == MessageState.ARRIVED) {
log.warn("We have already an ACKNOWLEDGED/ARRIVED message received. " +
if (messageStateProperty.get() == MessageState.ACKNOWLEDGED) {
log.warn("We have already an ACKNOWLEDGED message received. " +
"We would not expect any other message after that. Received messageState={}", messageState);
return;
}

View file

@ -22,7 +22,6 @@ import haveno.common.UserThread;
import haveno.common.app.DevEnv;
import haveno.common.util.Tuple4;
import haveno.core.locale.Res;
import haveno.core.network.MessageState;
import haveno.core.offer.Offer;
import haveno.core.payment.PaymentAccount;
import haveno.core.payment.PaymentAccountUtil;
@ -158,7 +157,7 @@ public class BuyerStep2View extends TradeStepView {
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(MessageState.SENT);
model.setMessageStateProperty(trade.getPaymentSentMessageState());
timeoutTimer = UserThread.runAfter(() -> {
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
@ -167,25 +166,25 @@ public class BuyerStep2View extends TradeStepView {
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
model.setMessageStateProperty(trade.getPaymentSentMessageState());
break;
case SELLER_RECEIVED_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
model.setMessageStateProperty(MessageState.ARRIVED);
model.setMessageStateProperty(trade.getPaymentSentMessageState());
break;
case BUYER_SEND_FAILED_PAYMENT_SENT_MSG:
// We get a popup and the trade closed, so we dont need to show anything here
busyAnimation.stop();
statusLabel.setText("");
model.setMessageStateProperty(MessageState.FAILED);
model.setMessageStateProperty(trade.getPaymentSentMessageState());
break;
default:
log.warn("Unexpected case: State={}, tradeId={} ", state.name(), trade.getId());
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
break;
}
}
}
});
}