fix warning about multiple acks on payment sent

This commit is contained in:
woodser 2024-01-14 13:51:33 -05:00
parent 7383ece7b3
commit 1f90ef1c88
2 changed files with 10 additions and 8 deletions

View File

@ -194,16 +194,17 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
}
}
public void setMessageStateProperty(MessageState messageState) {
public void setMessageStatePropertyIfNotAcked(MessageState messageState) {
// skip if already acked
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;
}
if (trade != null)
if (trade != null) {
trade.getProcessModel().setPaymentSentMessageState(messageState);
}
}
private void onMessageStateChanged(MessageState messageState) {
messageStateProperty.set(messageState);

View File

@ -22,6 +22,7 @@ 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;
@ -157,7 +158,7 @@ public class BuyerStep2View extends TradeStepView {
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(trade.getPaymentSentMessageState());
model.setMessageStatePropertyIfNotAcked(MessageState.SENT);
timeoutTimer = UserThread.runAfter(() -> {
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
@ -166,18 +167,18 @@ public class BuyerStep2View extends TradeStepView {
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
model.setMessageStateProperty(trade.getPaymentSentMessageState());
model.setMessageStatePropertyIfNotAcked(MessageState.STORED_IN_MAILBOX);
break;
case SELLER_RECEIVED_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
model.setMessageStateProperty(trade.getPaymentSentMessageState());
model.setMessageStatePropertyIfNotAcked(MessageState.ARRIVED);
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(trade.getPaymentSentMessageState());
model.setMessageStatePropertyIfNotAcked(MessageState.FAILED);
break;
default:
log.warn("Unexpected case: State={}, tradeId={} ", state.name(), trade.getId());