confirm payment sent and received off main thread

This commit is contained in:
woodser 2022-07-30 16:07:29 -04:00
parent 50126874a0
commit 3d43ae1f20
4 changed files with 90 additions and 82 deletions

View file

@ -159,41 +159,42 @@ public class BuyerStep2View extends TradeStepView {
showPopup();
} else if (state.ordinal() <= Trade.State.BUYER_SEND_FAILED_PAYMENT_SENT_MSG.ordinal()) {
if (!trade.hasFailed()) {
UserThread.execute(() -> {
switch (state) {
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT:
case BUYER_SENT_PAYMENT_SENT_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(MessageState.SENT);
timeoutTimer = UserThread.runAfter(() -> {
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
}, 10);
break;
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
model.setMessageStateProperty(MessageState.ARRIVED);
break;
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
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);
break;
default:
log.warn("Unexpected case: State={}, tradeId={} " + state.name(), trade.getId());
switch (state) {
case BUYER_CONFIRMED_IN_UI_PAYMENT_SENT:
busyAnimation.play();
statusLabel.setText("Confirming payment sent...");
break;
case BUYER_SENT_PAYMENT_SENT_MSG:
busyAnimation.play();
statusLabel.setText(Res.get("shared.sendingConfirmation"));
model.setMessageStateProperty(MessageState.SENT);
timeoutTimer = UserThread.runAfter(() -> {
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
break;
}
});
}, 10);
break;
case BUYER_SAW_ARRIVED_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageArrived"));
model.setMessageStateProperty(MessageState.ARRIVED);
break;
case BUYER_STORED_IN_MAILBOX_PAYMENT_SENT_MSG:
busyAnimation.stop();
statusLabel.setText(Res.get("shared.messageStoredInMailbox"));
model.setMessageStateProperty(MessageState.STORED_IN_MAILBOX);
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);
break;
default:
log.warn("Unexpected case: State={}, tradeId={} " + state.name(), trade.getId());
busyAnimation.stop();
statusLabel.setText(Res.get("shared.sendingConfirmationAgain"));
break;
}
} else {
log.warn("Trade contains error message {}", trade.getErrorMessage());
statusLabel.setText("");

View file

@ -120,6 +120,9 @@ public class SellerStep3View extends TradeStepView {
if (!trade.hasFailed()) {
switch (state) {
case SELLER_CONFIRMED_IN_UI_PAYMENT_RECEIPT:
busyAnimation.play();
statusLabel.setText(Res.get("Confirming payment received..."));
break;
case SELLER_PUBLISHED_PAYOUT_TX:
case SELLER_SENT_PAYOUT_TX_PUBLISHED_MSG:
case SELLER_SENT_PAYMENT_RECEIVED_MSG: