From c908294250de029bcbcba53abe70f37d3437a7d4 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 1 Feb 2024 13:00:37 -0500 Subject: [PATCH] set payment sent message state after sending message --- .../core/trade/protocol/TradeProtocol.java | 2 +- .../BuyerSendPaymentSentMessageToSeller.java | 25 +++++++++++++++++++ .../pendingtrades/PendingTradesViewModel.java | 12 --------- .../steps/buyer/BuyerStep2View.java | 5 ---- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java index 84487fbac6..ea9de573ef 100644 --- a/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java +++ b/core/src/main/java/haveno/core/trade/protocol/TradeProtocol.java @@ -486,7 +486,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D synchronized (trade) { if (!trade.isInitialized() || trade.isShutDown()) return; if (trade.getPhase().ordinal() >= Trade.Phase.PAYMENT_SENT.ordinal()) { - log.warn("Received another PaymentSentMessage which was already processed, ACKing"); + log.warn("Received another PaymentSentMessage which was already processed for {} {}, ACKing", trade.getClass().getSimpleName(), trade.getId()); handleTaskRunnerSuccess(peer, message); return; } diff --git a/core/src/main/java/haveno/core/trade/protocol/tasks/BuyerSendPaymentSentMessageToSeller.java b/core/src/main/java/haveno/core/trade/protocol/tasks/BuyerSendPaymentSentMessageToSeller.java index f7c9058d06..caf402be0a 100644 --- a/core/src/main/java/haveno/core/trade/protocol/tasks/BuyerSendPaymentSentMessageToSeller.java +++ b/core/src/main/java/haveno/core/trade/protocol/tasks/BuyerSendPaymentSentMessageToSeller.java @@ -18,6 +18,7 @@ package haveno.core.trade.protocol.tasks; import haveno.common.taskrunner.TaskRunner; +import haveno.core.network.MessageState; import haveno.core.trade.Trade; import haveno.core.trade.messages.TradeMessage; import haveno.core.trade.protocol.TradePeer; @@ -36,6 +37,30 @@ public class BuyerSendPaymentSentMessageToSeller extends BuyerSendPaymentSentMes protected TradePeer getReceiver() { return trade.getSeller(); } + + @Override + protected void setStateSent() { + trade.getProcessModel().setPaymentSentMessageState(MessageState.SENT); + super.setStateSent(); + } + + @Override + protected void setStateArrived() { + trade.getProcessModel().setPaymentSentMessageState(MessageState.ARRIVED); + super.setStateArrived(); + } + + @Override + protected void setStateStoredInMailbox() { + trade.getProcessModel().setPaymentSentMessageState(MessageState.STORED_IN_MAILBOX); + super.setStateStoredInMailbox(); + } + + @Override + protected void setStateFault() { + trade.getProcessModel().setPaymentSentMessageState(MessageState.FAILED); + super.setStateFault(); + } // continue execution on fault so payment sent message is sent to arbitrator @Override diff --git a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index 0a68b04afa..5f7a934ed8 100644 --- a/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -194,18 +194,6 @@ public class PendingTradesViewModel extends ActivatableWithDataModel { busyAnimation.stop(); statusLabel.setText(Res.get("shared.sendingConfirmationAgain")); @@ -167,18 +165,15 @@ public class BuyerStep2View extends TradeStepView { case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG: busyAnimation.stop(); statusLabel.setText(Res.get("shared.messageStoredInMailbox")); - model.setMessageStatePropertyIfNotAcked(MessageState.STORED_IN_MAILBOX); break; case SELLER_RECEIVED_PAYMENT_SENT_MSG: busyAnimation.stop(); statusLabel.setText(Res.get("shared.messageArrived")); - 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.setMessageStatePropertyIfNotAcked(MessageState.FAILED); break; default: log.warn("Unexpected case: State={}, tradeId={} ", state.name(), trade.getId());