Skip to content

Commit

Permalink
fix warning about multiple acks on payment sent
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Jan 14, 2024
1 parent b5a6232 commit 4bc5f12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ public void onSelectedItemChanged(PendingTradesListItem selectedItem) {
}
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -157,7 +158,7 @@ public void activate() {
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"));
Expand All @@ -166,18 +167,18 @@ public void activate() {
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());
Expand Down

0 comments on commit 4bc5f12

Please sign in to comment.