set payment sent message state after sending message

This commit is contained in:
woodser 2024-02-01 13:00:37 -05:00
parent fabec9d396
commit c908294250
4 changed files with 26 additions and 18 deletions

View File

@ -486,7 +486,7 @@ public abstract class TradeProtocol implements DecryptedDirectMessageListener, D
synchronized (trade) { synchronized (trade) {
if (!trade.isInitialized() || trade.isShutDown()) return; if (!trade.isInitialized() || trade.isShutDown()) return;
if (trade.getPhase().ordinal() >= Trade.Phase.PAYMENT_SENT.ordinal()) { 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); handleTaskRunnerSuccess(peer, message);
return; return;
} }

View File

@ -18,6 +18,7 @@
package haveno.core.trade.protocol.tasks; package haveno.core.trade.protocol.tasks;
import haveno.common.taskrunner.TaskRunner; import haveno.common.taskrunner.TaskRunner;
import haveno.core.network.MessageState;
import haveno.core.trade.Trade; import haveno.core.trade.Trade;
import haveno.core.trade.messages.TradeMessage; import haveno.core.trade.messages.TradeMessage;
import haveno.core.trade.protocol.TradePeer; import haveno.core.trade.protocol.TradePeer;
@ -36,6 +37,30 @@ public class BuyerSendPaymentSentMessageToSeller extends BuyerSendPaymentSentMes
protected TradePeer getReceiver() { protected TradePeer getReceiver() {
return trade.getSeller(); 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 // continue execution on fault so payment sent message is sent to arbitrator
@Override @Override

View File

@ -194,18 +194,6 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
} }
} }
public void setMessageStatePropertyIfNotAcked(MessageState messageState) {
// skip if already acked
if (messageStateProperty.get() == MessageState.ACKNOWLEDGED) {
return;
}
if (trade != null) {
trade.getProcessModel().setPaymentSentMessageState(messageState);
}
}
private void onMessageStateChanged(MessageState messageState) { private void onMessageStateChanged(MessageState messageState) {
messageStateProperty.set(messageState); messageStateProperty.set(messageState);
} }

View File

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